3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?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"; }
based on bTW4M
Output for 7.3.0alpha1
---------- throwing Catched exception: Object of class stdClass could not be converted to string
Output for 7.0.0 - 7.2.6
throwing Catched exception: Object of class stdClass could not be converted to string ----------
Output for 5.6.0 - 5.6.30, hhvm-3.15.4
----------