3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { private $field; function __construct(){ $this->field = new B; } function __debugInfo(){ return ["should only appear in dump"]; } } class B { private $field; function __construct(){ $this->field = new stdclass; } function __debugInfo(){ return ["should only appear in dump"]; } } $not_debug = (array)new A; var_dump($not_debug); var_export($not_debug);
Output for 8.2.0 - 8.2.29, 8.3.0 - 8.3.25, 8.4.1 - 8.4.12
array(1) { ["Afield"]=> object(B)#2 (1) { [0]=> string(26) "should only appear in dump" } } array ( '' . "\0" . 'A' . "\0" . 'field' => \B::__set_state(array( 'field' => (object) array( ), )), )
Output for 7.3.16 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.33
array(1) { ["Afield"]=> object(B)#2 (1) { [0]=> string(26) "should only appear in dump" } } array ( '' . "\0" . 'A' . "\0" . 'field' => B::__set_state(array( 'field' => (object) array( ), )), )
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.20, 7.2.0 - 7.2.33
array(1) { ["Afield"]=> object(B)#2 (1) { [0]=> string(26) "should only appear in dump" } } array ( '' . "\0" . 'A' . "\0" . 'field' => B::__set_state(array( 'field' => stdClass::__set_state(array( )), )), )

preferences:
127.85 ms | 410 KiB | 5 Q