3v4l.org

run code in 300+ PHP versions simultaneously
<?php header('Content-Type: text/plain'); function errorHandler($errno, $errstr, $errfile, $errline) { if ($errno === E_RECOVERABLE_ERROR) { $foo = []; asort($foo); echo $errstr . PHP_EOL; return true; } return false; } set_error_handler('errorHandler'); $key = [ (int) 0 => 'foo' ]; $select = [ 'id' => new stdClass(), 'foo' => 'foo', 'bar' => 'bar' ]; $missingFields = array_diff($key, $select) !== []; var_dump($missingFields);
Output for 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.25, 8.4.1 - 8.4.12
Fatal error: Uncaught Error: Object of class stdClass could not be converted to string in /in/2nT5M:23 Stack trace: #0 /in/2nT5M(23): array_diff(Array, Array) #1 {main} thrown in /in/2nT5M on line 23
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.33
Object of class stdClass could not be converted to string bool(false)
Output for 5.6.0 - 5.6.40
Object of class stdClass could not be converted to string bool(true)

preferences:
144.37 ms | 408 KiB | 5 Q