3v4l.org

run code in 300+ PHP versions simultaneously
<?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; // valid echo $B->a; // shouldn't be possible echo $B->getA() // valid
Output for 5.4.0 - 5.4.17
Parse error: syntax error, unexpected end of file, expecting ',' or ';' in /in/J4euu on line 44
Process exited with code 255.
Output for 5.3.0 - 5.3.27
Parse error: syntax error, unexpected $end, expecting ',' or ';' in /in/J4euu on line 44
Process exited with code 255.

preferences:
175.41 ms | 1395 KiB | 53 Q