3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?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 5.6.0 - 7.1.7, 7.3.0alpha1
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 7.2.5 - 7.2.6
Warning: include_once(): open_basedir restriction in effect. File(dbconfig.php) is not within the allowed path(s): (/tmp:/in) 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