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.31, 8.2.0 - 8.2.27, 8.3.0 - 8.3.16, 8.4.1 - 8.4.3
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:
120.46 ms | 417 KiB | 5 Q