3v4l.org

run code in 300+ PHP versions simultaneously
<?php namespace work; class Test1 {} $a = (object)[]; $b = new \stdClass(); $data = [$a, $b, new Test1()]; $result = json_encode($data); var_dump($result); echo str_repeat('-', 100) . PHP_EOL; $result1 = json_decode($result); $result2 = json_decode($result, true); $result1_1 = json_encode($result1); $result2_1 = json_encode($result2); var_dump($result1_1, $result2_1);
Output for 8.1.0 - 8.1.34, 8.2.0 - 8.2.30, 8.3.0 - 8.3.30, 8.4.1 - 8.4.18, 8.5.0 - 8.5.3
string(10) "[{},{},{}]" ---------------------------------------------------------------------------------------------------- string(10) "[{},{},{}]" string(10) "[[],[],[]]"

preferences:
42.7 ms | 1008 KiB | 4 Q