3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Test { protected $test = ''; } $test = new Test(); echo 'before' . PHP_EOL; foreach ($test as $key => $value) { echo $key . ' ' . $value . PHP_EOL; } $test->testing = 'testing'; $test->_testing = 'testing2'; echo 'after' . PHP_EOL; foreach ($test as $key => $value) { echo $key . ' ' . $value . PHP_EOL; } var_dump($test); $test2 = unserialize(base64_decode(base64_encode(serialize($test)))); var_dump($test2); echo 'round2' . PHP_EOL; foreach ($test as $key => $value) { echo $key . ' ' . $value . PHP_EOL; }
based on 0iPE9
Output for 5.3.0 - 5.6.30, hhvm-3.10.1 - 3.17.3, 7.0.0 - 7.3.0rc3
before after testing testing _testing testing2 object(Test)#1 (3) { ["test":protected]=> string(0) "" ["testing"]=> string(7) "testing" ["_testing"]=> string(8) "testing2" } object(Test)#2 (3) { ["test":protected]=> string(0) "" ["testing"]=> string(7) "testing" ["_testing"]=> string(8) "testing2" } round2 testing testing _testing testing2
Output for 5.0.2 - 5.2.17
before after testing testing _testing testing2 object(Test)#1 (3) { ["test:protected"]=> string(0) "" ["testing"]=> string(7) "testing" ["_testing"]=> string(8) "testing2" } object(Test)#2 (3) { ["test:protected"]=> string(0) "" ["testing"]=> string(7) "testing" ["_testing"]=> string(8) "testing2" } round2 testing testing _testing testing2
Output for 5.0.0 - 5.0.1
Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/GYZnX on line 9 beforePHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/GYZnX on line 16 afterPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/GYZnX on line 18 testing testingPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/GYZnX on line 18 _testing testing2PHP_EOLobject(Test)#1 (3) { ["test:protected"]=> string(0) "" ["testing"]=> string(7) "testing" ["_testing"]=> string(8) "testing2" } object(Test)#2 (3) { ["test:protected"]=> string(0) "" ["testing"]=> string(7) "testing" ["_testing"]=> string(8) "testing2" } Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/GYZnX on line 23 round2PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/GYZnX on line 25 testing testingPHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/GYZnX on line 25 _testing testing2PHP_EOL
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/GYZnX on line 5
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/GYZnX on line 5
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/GYZnX on line 5
Process exited with code 255.