Created
April 17, 2010 04:31
-
-
Save co3k/369265 to your computer and use it in GitHub Desktop.
Indirect modification of overloaded property ... を再現させるコード
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class ebisan | |
{ | |
public $kani = array(); | |
public function __get($name) | |
{ | |
return $this->kani[$name]; | |
} | |
public function __set($name, $value) | |
{ | |
return $this->kani[$name] = $value; | |
} | |
} | |
$ebisan = new ebisan(); | |
$ebisan->teriyaki = 'tetete'; | |
$ebisan->teriyakis = array('tetete'); | |
// Notice でない | |
var_dump($ebisan->teriyaki); | |
unset($ebisan->teriyaki); | |
var_dump($ebisan->teriyaki); | |
echo '========================='.PHP_EOL; | |
// Notice でる | |
var_dump($ebisan->teriyakis); | |
unset($ebisan->teriyakis[0]); | |
var_dump($ebisan->teriyakis); // 消えてない |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment