3v4l.org

run code in 300+ PHP versions simultaneously
<?php $errorHandler = new ErrorHandler; set_error_handler([$errorHandler, 'onError']); foreach (['SORT_REGULAR', 'SORT_NUMERIC', 'SORT_STRING', 'SORT_LOCALE_STRING'] as $sort_mode) { echo $sort_mode . ' - '; try { array_unique([new stdClass, new stdClass], constant($sort_mode)); echo 'works'; if ($errors = $errorHandler->getErrors()) { echo ', but with these errors: ' . PHP_EOL; var_dump($errors); $errorHandler->flush(); } else { echo PHP_EOL; } } catch (Throwable $e) { echo 'fails with the following error:' . PHP_EOL; echo $e->getMessage() . PHP_EOL; } echo PHP_EOL; } class ErrorHandler { private $errors = []; public function onError() { $this->errors[] = func_get_args()[1]; return true; } public function flush() { $this->errors = []; } public function getErrors() { return $this->errors; } }
Output for git.master, git.master_jit, rfc.property-hooks
SORT_REGULAR - works SORT_NUMERIC - works, but with these errors: array(4) { [0]=> string(56) "Object of class stdClass could not be converted to float" [1]=> string(56) "Object of class stdClass could not be converted to float" [2]=> string(56) "Object of class stdClass could not be converted to float" [3]=> string(56) "Object of class stdClass could not be converted to float" } SORT_STRING - fails with the following error: Object of class stdClass could not be converted to string SORT_LOCALE_STRING - fails with the following error: Object of class stdClass could not be converted to string

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:
119.86 ms | 407 KiB | 5 Q