3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Foo { public $str; public function __toString() { return $this->str; } } $a = new Foo();$a->str = '111'; $b = new Foo();$b->str = '1b'; $c = new Foo();$b->str = '1A'; $list = [$a, $b, $c]; natcasesort($list); print_r($list);
based on msYeu
Output for 7.1.0 - 7.2.0
Recoverable fatal error: Method Foo::__toString() must return a string value in /in/463Uv on line 18
Process exited with code 255.
Output for 5.4.10 - 7.0.20
Catchable fatal error: Method Foo::__toString() must return a string value in /in/463Uv on line 18
Process exited with code 255.
Output for 5.3.20 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/463Uv on line 16
Process exited with code 255.