3v4l.org

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

preferences:
31.43 ms | 402 KiB | 5 Q