3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * sort() triggers type-conversion notice * @link https://bugs.php.net/bug.php?id=64580 */ function obj($prop) { // return array($prop); global $objects; isset($objects) || $objects = 0; $objects++; return (object) array('prop' => $prop); } function tostring($val) { if (is_object($val)) { $val = sprintf('obj(%s)', $val->prop); } if (is_array($val)) { $val = '[' . implode(',', $val) . ']'; } return $val; } function handler() { global $errors; isset($errors) || $errors = 0; $errors++; return FALSE; } $subject = array(3, 3, 2, 3, 3, 2, 2, 3, 3, 1, 1, obj(1), 1, obj(1.2), 2, obj(2), 2, 2, 2, 2, obj(2.1), 1, 0, 0); set_error_handler('handler'); sort($subject); set_error_handler(FALSE); printf("sort caused %d error(s) in an array of %d member(s) of which %d are object(s).\n", $errors, count($subject), $objects); echo 'sort()-result: ', implode(', ', array_map('tostring', $subject));
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.27, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
Notice: Object of class stdClass could not be converted to int in /in/BoeCM on line 34 Notice: Object of class stdClass could not be converted to int in /in/BoeCM on line 34 Notice: Object of class stdClass could not be converted to int in /in/BoeCM on line 34 Notice: Object of class stdClass could not be converted to int in /in/BoeCM on line 34 Notice: Object of class stdClass could not be converted to int in /in/BoeCM on line 34 Notice: Object of class stdClass could not be converted to int in /in/BoeCM on line 34 Notice: Object of class stdClass could not be converted to int in /in/BoeCM on line 34 Notice: Object of class stdClass could not be converted to int in /in/BoeCM on line 34 Notice: Object of class stdClass could not be converted to int in /in/BoeCM on line 34 Notice: Object of class stdClass could not be converted to int in /in/BoeCM on line 34 Notice: Object of class stdClass could not be converted to int in /in/BoeCM on line 34 Notice: Object of class stdClass could not be converted to int in /in/BoeCM on line 34 Notice: Object of class stdClass could not be converted to int in /in/BoeCM on line 34 Notice: Object of class stdClass could not be converted to int in /in/BoeCM on line 34 Notice: Object of class stdClass could not be converted to int in /in/BoeCM on line 34 Fatal error: Uncaught TypeError: set_error_handler(): Argument #1 ($callback) must be a valid callback or null, no array or string given in /in/BoeCM:35 Stack trace: #0 /in/BoeCM(35): set_error_handler(false) #1 {main} thrown in /in/BoeCM on line 35
Process exited with code 255.
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 Notice: Object of class stdClass could not be converted to int in /in/BoeCM on line 34 Notice: Object of class stdClass could not be converted to int in /in/BoeCM on line 34 Notice: Object of class stdClass could not be converted to int in /in/BoeCM on line 34 Notice: Object of class stdClass could not be converted to int in /in/BoeCM on line 34 Notice: Object of class stdClass could not be converted to int in /in/BoeCM on line 34 Notice: Object of class stdClass could not be converted to int in /in/BoeCM on line 34 Notice: Object of class stdClass could not be converted to int in /in/BoeCM on line 34 Notice: Object of class stdClass could not be converted to int in /in/BoeCM on line 34 Notice: Object of class stdClass could not be converted to int in /in/BoeCM on line 34 Notice: Object of class stdClass could not be converted to int in /in/BoeCM on line 34 Notice: Object of class stdClass could not be converted to int in /in/BoeCM on line 34 Notice: Object of class stdClass could not be converted to int in /in/BoeCM on line 34 Notice: Object of class stdClass could not be converted to int in /in/BoeCM on line 34 Notice: Object of class stdClass could not be converted to int in /in/BoeCM on line 34 Notice: Object of class stdClass could not be converted to int in /in/BoeCM on line 34 Fatal error: Uncaught TypeError: set_error_handler(): Argument #1 ($callback) must be a valid callback or null, no array or string given in /in/BoeCM:35 Stack trace: #0 /in/BoeCM(35): set_error_handler(false) #1 {main} thrown in /in/BoeCM on line 35
Process exited with code 255.
Output for 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.31, 7.4.0 - 7.4.33
Notice: Object of class stdClass could not be converted to int in /in/BoeCM on line 34 Notice: Object of class stdClass could not be converted to int in /in/BoeCM on line 34 Notice: Object of class stdClass could not be converted to int in /in/BoeCM on line 34 Notice: Object of class stdClass could not be converted to int in /in/BoeCM on line 34 Notice: Object of class stdClass could not be converted to int in /in/BoeCM on line 34 Notice: Object of class stdClass could not be converted to int in /in/BoeCM on line 34 Notice: Object of class stdClass could not be converted to int in /in/BoeCM on line 34 Notice: Object of class stdClass could not be converted to int in /in/BoeCM on line 34 Notice: Object of class stdClass could not be converted to int in /in/BoeCM on line 34 Warning: set_error_handler() expects the argument () to be a valid callback in /in/BoeCM on line 35 sort caused 10 error(s) in an array of 24 member(s) of which 4 are object(s). sort()-result: 0, 0, 1, 1, obj(1), obj(1.2), obj(2), obj(2.1), 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3
Output for 7.3.32 - 7.3.33
Warning: set_error_handler() expects the argument () to be a valid callback in /in/BoeCM on line 35 sort caused 10 error(s) in an array of 24 member(s) of which 4 are object(s). sort()-result: 0, 0, 1, 1, obj(1), obj(1.2), obj(2), obj(2.1), 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3
Output for 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.40
Notice: Object of class stdClass could not be converted to int in /in/BoeCM on line 34 Notice: Object of class stdClass could not be converted to int in /in/BoeCM on line 34 Notice: Object of class stdClass could not be converted to int in /in/BoeCM on line 34 Notice: Object of class stdClass could not be converted to int in /in/BoeCM on line 34 Notice: Object of class stdClass could not be converted to int in /in/BoeCM on line 34 Notice: Object of class stdClass could not be converted to int in /in/BoeCM on line 34 Notice: Object of class stdClass could not be converted to int in /in/BoeCM on line 34 Notice: Object of class stdClass could not be converted to int in /in/BoeCM on line 34 Notice: Object of class stdClass could not be converted to int in /in/BoeCM on line 34 Notice: Object of class stdClass could not be converted to int in /in/BoeCM on line 34 Notice: Object of class stdClass could not be converted to int in /in/BoeCM on line 34 Notice: Object of class stdClass could not be converted to int in /in/BoeCM on line 34 Notice: Object of class stdClass could not be converted to int in /in/BoeCM on line 34 Notice: Object of class stdClass could not be converted to int in /in/BoeCM on line 34 Notice: Object of class stdClass could not be converted to int in /in/BoeCM on line 34 Notice: Object of class stdClass could not be converted to int in /in/BoeCM on line 34 Notice: Object of class stdClass could not be converted to int in /in/BoeCM on line 34 Notice: Object of class stdClass could not be converted to int in /in/BoeCM on line 34 Notice: Object of class stdClass could not be converted to int in /in/BoeCM on line 34 Notice: Object of class stdClass could not be converted to int in /in/BoeCM on line 34 Notice: Object of class stdClass could not be converted to int in /in/BoeCM on line 34 Notice: Object of class stdClass could not be converted to int in /in/BoeCM on line 34 Notice: Object of class stdClass could not be converted to int in /in/BoeCM on line 34 Notice: Object of class stdClass could not be converted to int in /in/BoeCM on line 34 Notice: Object of class stdClass could not be converted to int in /in/BoeCM on line 34 Notice: Object of class stdClass could not be converted to int in /in/BoeCM on line 34 Notice: Object of class stdClass could not be converted to int in /in/BoeCM on line 34 Notice: Object of class stdClass could not be converted to int in /in/BoeCM on line 34 Notice: Object of class stdClass could not be converted to int in /in/BoeCM on line 34 Notice: Object of class stdClass could not be converted to int in /in/BoeCM on line 34 Notice: Object of class stdClass could not be converted to int in /in/BoeCM on line 34 Notice: Object of class stdClass could not be converted to int in /in/BoeCM on line 34 Notice: Object of class stdClass could not be converted to int in /in/BoeCM on line 34 Notice: Object of class stdClass could not be converted to int in /in/BoeCM on line 34 Notice: Object of class stdClass could not be converted to int in /in/BoeCM on line 34 Notice: Object of class stdClass could not be converted to int in /in/BoeCM on line 34 Notice: Object of class stdClass could not be converted to int in /in/BoeCM on line 34 Notice: Object of class stdClass could not be converted to int in /in/BoeCM on line 34 Notice: Object of class stdClass could not be converted to int in /in/BoeCM on line 34 Notice: Object of class stdClass could not be converted to int in /in/BoeCM on line 34 Notice: Object of class stdClass could not be converted to int in /in/BoeCM on line 34 Notice: Object of class stdClass could not be converted to int in /in/BoeCM on line 34 Notice: Object of class stdClass could not be converted to int in /in/BoeCM on line 34 Warning: set_error_handler() expects the argument () to be a valid callback in /in/BoeCM on line 35 sort caused 44 error(s) in an array of 24 member(s) of which 4 are object(s). sort()-result: 0, 0, 1, 1, 1, 1, obj(1), obj(1.2), obj(2), obj(2.1), 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3
Output for 5.0.3 - 5.0.5
Warning: set_error_handler() expects the argument () to be a valid callback in /in/BoeCM on line 35 sort caused 1 error(s) in an array of 24 member(s) of which 4 are object(s). sort()-result: 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, obj(1), obj(1.2), obj(2), obj(2.1)
Output for 4.3.7 - 4.3.9, 5.0.0 - 5.0.2

Process exited with code 139.
Output for 4.3.10 - 4.3.11, 4.4.0 - 4.4.9
Warning: set_error_handler() expects argument 1, '', to be a valid callback in /in/BoeCM on line 35 sort caused 1 error(s) in an array of 24 member(s) of which 4 are object(s). sort()-result: 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, obj(1), obj(1.2), obj(2), obj(2.1)
Output for 4.3.0 - 4.3.6
sort caused 1 error(s) in an array of 24 member(s) of which 4 are object(s). sort()-result: 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, obj(1), obj(1.2), obj(2), obj(2.1)

preferences:
352.11 ms | 401 KiB | 459 Q