3v4l.org

run code in 200+ PHP versions simultaneously
<?php class A { public $prop = [1,2,3]; } class B{ public $someProp; } $a = new A; $b = new B; $b->someProp = $a->prop; mb_convert_variables('UTF-8', 'CP1252', $b); $a = new A; print_r($a); # example 2 class C { public $prop = ['string', 'string2']; } $c = new C; mb_convert_variables('UTF-8', 'CP1252', $c); $c = new C; print_r($c);
Output for 5.4.0 - 5.6.26, 7.0.0 - 7.0.11, 7.3.0 - 7.4.3
A Object ( [prop] => Array ( [0] => 1 [1] => 2 [2] => 3 ) ) C Object ( [prop] => Array ( [0] => string [1] => string2 ) )
Output for 5.6.27 - 5.6.40, 7.0.12 - 7.2.28
A Object ( [prop] => Array *RECURSION* ) C Object ( [prop] => Array *RECURSION* )
Output for 5.1.0 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/d8fth on line 4
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Parse error: parse error, unexpected '[' in /in/d8fth on line 4
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/d8fth on line 4
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/d8fth on line 4
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/d8fth on line 4
Process exited with code 255.