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"; }
Output for git.master, git.master_jit, rfc.property-hooks
---------- Fatal error: Uncaught Error: Object of class stdClass could not be converted to string in /in/RYIo5:22 Stack trace: #0 /in/RYIo5(22): array_diff(Array, Array) #1 {main} thrown in /in/RYIo5 on line 22
Process exited with code 255.

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
49.68 ms | 401 KiB | 8 Q