3v4l.org

run code in 300+ PHP versions simultaneously
<?php include_once 'dbconfig.php'; $method = $_SERVER['REQUEST_METHOD']; switch($method) { case 'POST': $data = json_decode($_POST['params']); $name = $data['name']; $sql_query = "INSERT INTO person(name) VALUES('$name')"; $result = mysqli_query($link, $sql_query); break; case 'GET': $uriParts = spliti ("/", $_SERVER['REQUEST_URI']); $id = end($uriParts); $sql_query="SELECT * FROM person WHERE id=".$id; $result_set=mysqli_query($link, $sql_query); $rows = array(); while($r = mysqli_fetch_assoc($result_set)) { $rows[] = $r; } break; } header('Content-type: application/json'); echo json_encode($rows);
Output for 8.0.0 - 8.0.12, 8.0.14 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
Warning: include_once(): open_basedir restriction in effect. File(dbconfig.php) is not within the allowed path(s): (/tmp:/in:/etc) in /in/rvn2F on line 2 Warning: include_once(dbconfig.php): Failed to open stream: Operation not permitted in /in/rvn2F on line 2 Warning: include_once(): Failed opening 'dbconfig.php' for inclusion (include_path='.:') in /in/rvn2F on line 2 Warning: Undefined array key "REQUEST_METHOD" in /in/rvn2F on line 4 Warning: Cannot modify header information - headers already sent by (output started at /in/rvn2F:2) in /in/rvn2F on line 26 Warning: Undefined variable $rows in /in/rvn2F on line 27 null
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 Warning: include_once(): open_basedir restriction in effect. File(dbconfig.php) is not within the allowed path(s): (/tmp:/in:/etc) in /in/rvn2F on line 2 Warning: include_once(dbconfig.php): Failed to open stream: Operation not permitted in /in/rvn2F on line 2 Warning: include_once(): Failed opening 'dbconfig.php' for inclusion (include_path='.:') in /in/rvn2F on line 2 Warning: Undefined array key "REQUEST_METHOD" in /in/rvn2F on line 4 Warning: Cannot modify header information - headers already sent by (output started at /in/rvn2F:2) in /in/rvn2F on line 26 Warning: Undefined variable $rows in /in/rvn2F on line 27 null
Output for 8.0.13
Warning: include_once(dbconfig.php): Failed to open stream: No such file or directory in /in/rvn2F on line 2 Warning: include_once(): Failed opening 'dbconfig.php' for inclusion (include_path='.:') in /in/rvn2F on line 2 Warning: Undefined array key "REQUEST_METHOD" in /in/rvn2F on line 4 Warning: Cannot modify header information - headers already sent by (output started at /in/rvn2F:2) in /in/rvn2F on line 26 Warning: Undefined variable $rows in /in/rvn2F on line 27 null
Output for 7.4.33
Warning: include_once(dbconfig.php): failed to open stream: No such file or directory in /in/rvn2F on line 2 Warning: include_once(): Failed opening 'dbconfig.php' for inclusion (include_path='.:') in /in/rvn2F on line 2 Notice: Undefined index: REQUEST_METHOD in /in/rvn2F on line 4 Warning: Cannot modify header information - headers already sent by (output started at /in/rvn2F:2) in /in/rvn2F on line 26 Notice: Undefined variable: rows in /in/rvn2F on line 27 null
Output for 5.6.0 - 5.6.40, 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.32
Warning: include_once(): open_basedir restriction in effect. File(dbconfig.php) is not within the allowed path(s): (/tmp:/in:/etc) in /in/rvn2F on line 2 Warning: include_once(dbconfig.php): failed to open stream: Operation not permitted in /in/rvn2F on line 2 Warning: include_once(): Failed opening 'dbconfig.php' for inclusion (include_path='.:') in /in/rvn2F on line 2 Notice: Undefined index: REQUEST_METHOD in /in/rvn2F on line 4 Warning: Cannot modify header information - headers already sent by (output started at /in/rvn2F:2) in /in/rvn2F on line 26 Notice: Undefined variable: rows in /in/rvn2F on line 27 null
Output for 7.3.32 - 7.3.33
Warning: include_once(dbconfig.php): failed to open stream: No such file or directory in /in/rvn2F on line 2 Warning: include_once(): Failed opening 'dbconfig.php' for inclusion (include_path='.:') in /in/rvn2F on line 2 Warning: Cannot modify header information - headers already sent by (output started at /in/rvn2F:2) in /in/rvn2F on line 26 null

preferences:
257.43 ms | 402 KiB | 291 Q