3v4l.org

run code in 300+ PHP versions simultaneously
<?php $_GET['page'] = '\'\''; if (isset($_GET['page'])) { $page = $_GET['page']; } else { $page = "home"; } $file = "templates/" . $page . ".php"; echo "strpos('$file', '..') === false"; // I heard '..' is dangerous! assert("strpos('$file', '..') === false") or die("Detected hacking attempt!"); // TODO: Make this look nice assert("file_exists('$file')") or die("That file doesn't exist!");
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
strpos('templates/''.php', '..') === false
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 strpos('templates/''.php', '..') === false
Output for 7.3.0 - 7.3.31, 7.4.0 - 7.4.33
strpos('templates/''.php', '..') === false Deprecated: assert(): Calling assert() with a string argument is deprecated in /in/815c7 on line 15 Fatal error: Uncaught ParseError: syntax error, unexpected ''.php'' (T_CONSTANT_ENCAPSED_STRING), expecting ')' in /in/815c7(15) : assert code:1 Stack trace: #0 /in/815c7(15): assert('strpos('templat...', 'assert("strpos(...') #1 {main} Next Error: Failure evaluating code: assert("strpos('$file', '..') === false"):"strpos('templates/''.php', '..') === false" in /in/815c7:15 Stack trace: #0 /in/815c7(15): assert('strpos('templat...', 'assert("strpos(...') #1 {main} thrown in /in/815c7 on line 15
Process exited with code 255.
Output for 7.3.32 - 7.3.33
strpos('templates/''.php', '..') === false Fatal error: Uncaught ParseError: syntax error, unexpected ''.php'' (T_CONSTANT_ENCAPSED_STRING), expecting ')' in /in/815c7(15) : assert code:1 Stack trace: #0 /in/815c7(15): assert('strpos('templat...', 'assert("strpos(...') #1 {main} Next Error: Failure evaluating code: assert("strpos('$file', '..') === false"):"strpos('templates/''.php', '..') === false" in /in/815c7:15 Stack trace: #0 /in/815c7(15): assert('strpos('templat...', 'assert("strpos(...') #1 {main} thrown in /in/815c7 on line 15
Process exited with code 255.
Output for 7.2.0 - 7.2.33
strpos('templates/''.php', '..') === false Deprecated: assert(): Calling assert() with a string argument is deprecated in /in/815c7 on line 15 Fatal error: Uncaught ParseError: syntax error, unexpected ''.php'' (T_CONSTANT_ENCAPSED_STRING), expecting ',' or ')' in /in/815c7(15) : assert code:1 Stack trace: #0 /in/815c7(15): assert('strpos('templat...', 'assert("strpos(...') #1 {main} Next Error: Failure evaluating code: assert("strpos('$file', '..') === false"):"strpos('templates/''.php', '..') === false" in /in/815c7:15 Stack trace: #0 /in/815c7(15): assert('strpos('templat...', 'assert("strpos(...') #1 {main} thrown in /in/815c7 on line 15
Process exited with code 255.
Output for 7.1.0 - 7.1.33
strpos('templates/''.php', '..') === false Fatal error: Uncaught ParseError: syntax error, unexpected ''.php'' (T_CONSTANT_ENCAPSED_STRING), expecting ',' or ')' in /in/815c7(15) : assert code:1 Stack trace: #0 /in/815c7(15): assert('strpos('templat...', 'assert("strpos(...') #1 {main} Next Error: Failure evaluating code: assert("strpos('$file', '..') === false"):"strpos('templates/''.php', '..') === false" in /in/815c7:15 Stack trace: #0 /in/815c7(15): assert('strpos('templat...', 'assert("strpos(...') #1 {main} thrown in /in/815c7 on line 15
Process exited with code 255.
Output for 7.0.0 - 7.0.33
strpos('templates/''.php', '..') === false Parse error: syntax error, unexpected ''.php'' (T_CONSTANT_ENCAPSED_STRING), expecting ',' or ')' in /in/815c7(15) : assert code on line 1 Catchable fatal error: assert(): Failure evaluating code: assert("strpos('$file', '..') === false"):"strpos('templates/''.php', '..') === false" in /in/815c7 on line 15
Process exited with code 255.
Output for 5.6.0 - 5.6.40
strpos('templates/''.php', '..') === false Parse error: syntax error, unexpected ''.php'' (T_CONSTANT_ENCAPSED_STRING) in /in/815c7(15) : assert code on line 1 Catchable fatal error: assert(): Failure evaluating code: strpos('templates/''.php', '..') === false in /in/815c7 on line 15
Process exited with code 255.

preferences:
215.28 ms | 401 KiB | 291 Q