3v4l.org

run code in 300+ PHP versions simultaneously
<?php $books["978-0743261690"] = "Gilgamesh"; $books["978-0060931957"] = "The Odyssey"; $books["978-0192840509"] = "Aesop's Fables"; $books["978-0520227040"] = "Mahabharta"; $books["978-0393320978"] = "Beowulf"; ?><html> <head> <title>Five Great Books</title> </head> <body> <h1>Five Great Books</h1> <ul> <?php foreach($books as $book) { ?> <li><?php echo key($book); ?></li> <?php } ?> </ul> </body> </html>
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
<html> <head> <title>Five Great Books</title> </head> <body> <h1>Five Great Books</h1> <ul> <li> Fatal error: Uncaught TypeError: key(): Argument #1 ($array) must be of type array, string given in /in/vuUhf:17 Stack trace: #0 /in/vuUhf(17): key('Gilgamesh') #1 {main} thrown in /in/vuUhf on line 17
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 <html> <head> <title>Five Great Books</title> </head> <body> <h1>Five Great Books</h1> <ul> <li> Fatal error: Uncaught TypeError: key(): Argument #1 ($array) must be of type array, string given in /in/vuUhf:17 Stack trace: #0 /in/vuUhf(17): key('Gilgamesh') #1 {main} thrown in /in/vuUhf on line 17
Process exited with code 255.
Output for 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.20, 7.2.0 - 7.2.33, 7.3.16 - 7.3.33, 7.4.0 - 7.4.33
<html> <head> <title>Five Great Books</title> </head> <body> <h1>Five Great Books</h1> <ul> <li> Warning: key() expects parameter 1 to be array, string given in /in/vuUhf on line 17 </li> <li> Warning: key() expects parameter 1 to be array, string given in /in/vuUhf on line 17 </li> <li> Warning: key() expects parameter 1 to be array, string given in /in/vuUhf on line 17 </li> <li> Warning: key() expects parameter 1 to be array, string given in /in/vuUhf on line 17 </li> <li> Warning: key() expects parameter 1 to be array, string given in /in/vuUhf on line 17 </li> </ul> </body> </html>
Output for 4.3.2 - 4.3.11, 4.4.0 - 4.4.9, 5.0.0 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17
<html> <head> <title>Five Great Books</title> </head> <body> <h1>Five Great Books</h1> <ul> <li> Warning: key(): Passed variable is not an array or object in /in/vuUhf on line 17 </li> <li> Warning: key(): Passed variable is not an array or object in /in/vuUhf on line 17 </li> <li> Warning: key(): Passed variable is not an array or object in /in/vuUhf on line 17 </li> <li> Warning: key(): Passed variable is not an array or object in /in/vuUhf on line 17 </li> <li> Warning: key(): Passed variable is not an array or object in /in/vuUhf on line 17 </li> </ul> </body> </html>
Output for 4.3.0 - 4.3.1
<html> <head> <title>Five Great Books</title> </head> <body> <h1>Five Great Books</h1> <ul> <li> Warning: key() [http://www.php.net/function.key]: Passed variable is not an array or object in /in/vuUhf on line 17 </li> <li> Warning: key() [http://www.php.net/function.key]: Passed variable is not an array or object in /in/vuUhf on line 17 </li> <li> Warning: key() [http://www.php.net/function.key]: Passed variable is not an array or object in /in/vuUhf on line 17 </li> <li> Warning: key() [http://www.php.net/function.key]: Passed variable is not an array or object in /in/vuUhf on line 17 </li> <li> Warning: key() [http://www.php.net/function.key]: Passed variable is not an array or object in /in/vuUhf on line 17 </li> </ul> </body> </html>

preferences:
224.23 ms | 403 KiB | 353 Q