run code in 200+ php & hhvm versions
Bugs & Features
<?php class foo{ public static $myvar = 99; public $myvar = 77; public function __construct(){ $this->myvar = 35; } public function printMyVar(){ echo '->printMyVar(): '.$this->myvar; } public function setMyVar($mv){ $this->myvar = $mv; } } echo 'foo::$myvar: '.foo::$myvar."\n"; $foo = new foo(); echo $foo->printMyVar(); echo "\n"; echo 'foo::$myvar: '.foo::$myvar."\n"; echo "Conclusion: when using \$this-> to change the value, it adds another non-static version rather than changing the static version";
Output for 5.3.0 - 5.4.20
Fatal error: Cannot redeclare foo::$myvar in /in/rMVg8 on line 5
Process exited with code 255.