3v4l.org

run code in 300+ PHP versions simultaneously
<?php set_error_handler(function (int $serverity, string $message, string $filename, int $line) { echo "throwing\n"; throw new ErrorException($message, 0, $serverity, $filename, $line); }); $stdObject = new stdClass(); //Can't be casted to string //array_diff compares array items CASTING them to string //http://php.net/manual/en/function.array-diff.php try { array_diff([], [$stdObject]); }catch(ErrorException $ee){ echo "Catched exception: " . $ee->getMessage() . "\n"; }

preferences:
57.13 ms | 402 KiB | 5 Q