3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php // Everything you enter here will be executed by our servers. Try it! class A { private $a; private $b; public function __construct() { $this->a = 1; $this->b = 2; } public function __get($name) { switch ($name) { // protected: case 'a': return $this->a; break; // public case 'b': return $this->b; break; } } } class B extends A { public function getA() { return $this->a; } } $B = new B(); echo $B->b . "\n"; // valid echo $B->a . "\n"; // shouldn't be possible echo $B->getA() . "\n"; // valid
Output for 5.0.0 - 5.0.5, 5.1.1 - 7.1.0
2 1 1
Output for 5.1.0
Fatal error: fatal flex scanner internal error--end of buffer missed in /in/Odehk on line 44
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/Odehk on line 6
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/Odehk on line 6
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/Odehk on line 6
Process exited with code 255.