3v4l.org

run code in 300+ PHP versions simultaneously
<?php function test() { $o1 = new stdClass; debug_zval_dump($o1); $o2 = new stdClass; $o2_copy = $o2; debug_zval_dump($o2_copy); $o3 = new stdClass; $o3_ref =& $o3; debug_zval_dump($o3_ref); $a1 = array(); $a1[] = 1; debug_zval_dump($a1); $a2 = array(); $a2[] = 2; $a2_copy = $a2; debug_zval_dump($a2_copy); $a3 = array(); $a3[] = 3; $a3_ref =& $a3; debug_zval_dump($a3_ref); $s1 = 'Hello'; $s1 .= ' World 1'; debug_zval_dump($s1); $s2 = 'Hello'; $s2 .= ' World 2'; $s2_copy = $s2; debug_zval_dump($s2_copy); $s3 = 'Hello'; $s3 .= ' World 3'; $s3_ref =& $s3; debug_zval_dump($s3_ref); $i1 = 1; debug_zval_dump($i1); $i2 = 2; $i2_copy = $i2; debug_zval_dump($i2_copy); $i3 = 3; $i3_ref =& $i3; debug_zval_dump($i3_ref); } test();
Output for 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.34, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
object(stdClass)#1 (0) refcount(2){ } object(stdClass)#2 (0) refcount(3){ } object(stdClass)#3 (0) refcount(2){ } array(1) refcount(2){ [0]=> int(1) } array(1) refcount(3){ [0]=> int(2) } array(1) refcount(2){ [0]=> int(3) } string(13) "Hello World 1" refcount(2) string(13) "Hello World 2" refcount(3) string(13) "Hello World 3" refcount(2) int(1) int(2) int(3)
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 object(stdClass)#1 (0) refcount(2){ } object(stdClass)#2 (0) refcount(3){ } object(stdClass)#3 (0) refcount(2){ } array(1) refcount(2){ [0]=> int(1) } array(1) refcount(3){ [0]=> int(2) } array(1) refcount(2){ [0]=> int(3) } string(13) "Hello World 1" refcount(2) string(13) "Hello World 2" refcount(3) string(13) "Hello World 3" refcount(2) int(1) int(2) int(3)
Output for 5.0.0 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.40
object(stdClass)#1 (0) refcount(2){ } object(stdClass)#2 (0) refcount(3){ } object(stdClass)#3 (0) refcount(1){ } array(1) refcount(2){ [0]=> long(1) refcount(1) } array(1) refcount(3){ [0]=> long(2) refcount(1) } array(1) refcount(1){ [0]=> long(3) refcount(2) } string(13) "Hello World 1" refcount(2) string(13) "Hello World 2" refcount(3) string(13) "Hello World 3" refcount(1) long(1) refcount(2) long(2) refcount(3) long(3) refcount(1)
Output for 4.3.0 - 4.3.11, 4.4.0 - 4.4.9
object(stdClass)(0) refcount(2){ } object(stdClass)(0) refcount(3){ } object(stdClass)(0) refcount(1){ } array(1) refcount(2){ [0]=> long(1) refcount(1) } array(1) refcount(3){ [0]=> long(2) refcount(1) } array(1) refcount(1){ [0]=> long(3) refcount(2) } string(13) "Hello World 1" refcount(2) string(13) "Hello World 2" refcount(3) string(13) "Hello World 3" refcount(1) long(1) refcount(2) long(2) refcount(3) long(3) refcount(1)

preferences:
312.37 ms | 402 KiB | 462 Q