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 8.0.1 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.28, 8.4.1 - 8.4.14, 8.5.0 - 8.5.1
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
Output for 8.4.15
/bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.35' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.34' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15)
Process exited with code 1.

preferences:
140.12 ms | 408 KiB | 5 Q