3v4l.org

run code in 300+ PHP versions simultaneously
<?php set_error_handler(function (int $severity, string $message, string $filename, int $line) { echo "throwing\n"; throw new ErrorException($message, 0, $severity, $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"; } echo "\n----------\n"; try { array_diff([$stdObject], []); }catch(ErrorException $ee){ echo "Catched exception: " . $ee->getMessage() . "\n"; }

preferences:
48.09 ms | 402 KiB | 5 Q