3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Test { public function __get( $property ) { if ( 'bla' === $property ) { echo 'Initializing Text->bla' . PHP_EOL; $this->bla = 'Value'; return $this->bla; } $message = sprintf( 'Undefined property: %s::$%s', get_class(), $property ); trigger_error( $message, E_USER_NOTICE); return null; } public function test_unset( $offset ) { unset $this->bla[ $offset ]; } } $test = new Test(); echo $test->bla[2] . PHP_EOL; $test->test_unset( 2 ); echo $test->bla . PHP_EOL; echo $test->bla . PHP_EOL; echo $test->bla . PHP_EOL; echo $test->kaka . PHP_EOL; echo $test->bla . PHP_EOL;
based on rYquP
Output for 5.6.0 - 5.6.30, 7.0.0 - 7.1.7
Parse error: syntax error, unexpected '$this' (T_VARIABLE), expecting '(' in /in/W2sba on line 21
Process exited with code 255.
Output for hhvm-3.15.4
Fatal error: Uncaught Error: syntax error, unexpected T_VARIABLE, expecting '(' in /in/W2sba:21 Stack trace: #0 {main}
Process exited with code 255.