3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Primary { public function __toString() { $GLOBALS['anObject'] = $this; return 'toString output from Primary'; } } $Foo = new Primary; str_replace('', '', $Foo); var_dump($GLOBALS['anObject']); // expected to be object of class Primary, actually string

preferences:
36.65 ms | 402 KiB | 5 Q