3v4l.org

run code in 300+ PHP versions simultaneously
<?php require_once('db.php'); require_once('response.php'); //require_once('connectDB'); //header('Access-Control-Allow-Methods: GET'); // function that redirects to another url function redirect($url, $statusCode = 404) { header('Location: ' . $url, true, $statusCode); die(); } //giving permission to access only for the specific IP if($_SERVER[REMOTE_ADDR]==='87.202.220.188') { //connection with the database include('connectDB.php'); // if it's not a post request, redirection to non-existent page if($_SERVER['REQUEST_METHOD'] !== 'POST') { redirect('http://paragon.gr/content/', false); } // check request's content type header is JSON if($_SERVER['CONTENT_TYPE'] !== 'application/json') { // set up response for unsuccessful request $response = new Response(); $response->setHttpStatusCode(400); $response->setSuccess(false); $response->addMessage("Content Type header not set to JSON"); $response->send(); exit; } // get POST request body as the POSTed data will be JSON format //$rawPostData = file_get_contents('php://input'); /* if(!$jsonData = json_decode($rawPostData)) { // set up response for unsuccessful request $response = new Response(); $response->setHttpStatusCode(400); $response->setSuccess(false); $response->addMessage("Request body is not valid JSON"); $response->send(); exit; } */ //triming name in case there are spaces in between $name = trim($jsonData->name); $test = $jsonData->test; // inserting the data in the database table // $query = $writeDB->prepare('UPDATE test_db (name, test) values (:name, :test) WHERE `test_db`.`id` = 12'); //UPDATE `test_db` SET `name` = 'ha!' WHERE `users`.`id` = 44 $query = $writeDB->prepare('UPDATE `test_db` SET `name` = `ha!` WHERE `users`.`id` = 44'); $query->bindParam(':name', $name, PDO::PARAM_STR); $query->bindParam(':test', $test, PDO::PARAM_STR); $query->execute(); $returnData = array(); // $returnData['user_id'] = $lastID; $returnData['name'] = $name; $returnData['test'] = $test; // .json format to show success when content is added to the database $response = new Response(); $response->setHttpStatusCode(201); $response->setSuccess(true); $response->addMessage("= created"); $response->setData($returnData); $response->send(); exit; // will put redirection link to send command to specific ip // to give and update on the location they are going to mine the data. } // redirection to non-existent page for the IPs without permission to access else{ redirect('http://paragon.gr/content/', false); } ?>
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: require_once(): open_basedir restriction in effect. File(db.php) is not within the allowed path(s): (/tmp:/in:/etc) in /in/pdH8j on line 2 Warning: require_once(db.php): Failed to open stream: Operation not permitted in /in/pdH8j on line 2 Fatal error: Uncaught Error: Failed opening required 'db.php' (include_path='.:') in /in/pdH8j:2 Stack trace: #0 {main} thrown in /in/pdH8j on line 2
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 Warning: require_once(): open_basedir restriction in effect. File(db.php) is not within the allowed path(s): (/tmp:/in:/etc) in /in/pdH8j on line 2 Warning: require_once(db.php): Failed to open stream: Operation not permitted in /in/pdH8j on line 2 Fatal error: Uncaught Error: Failed opening required 'db.php' (include_path='.:') in /in/pdH8j:2 Stack trace: #0 {main} thrown in /in/pdH8j on line 2
Process exited with code 255.
Output for 8.0.13
Warning: require_once(db.php): Failed to open stream: No such file or directory in /in/pdH8j on line 2 Fatal error: Uncaught Error: Failed opening required 'db.php' (include_path='.:') in /in/pdH8j:2 Stack trace: #0 {main} thrown in /in/pdH8j on line 2
Process exited with code 255.
Output for 7.3.32, 7.4.26, 7.4.33
Warning: require_once(db.php): failed to open stream: No such file or directory in /in/pdH8j on line 2 Fatal error: require_once(): Failed opening required 'db.php' (include_path='.:') in /in/pdH8j on line 2
Process exited with code 255.
Output for 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.31, 7.3.33, 7.4.0 - 7.4.25, 7.4.27 - 7.4.32
Warning: require_once(): open_basedir restriction in effect. File(db.php) is not within the allowed path(s): (/tmp:/in:/etc) in /in/pdH8j on line 2 Warning: require_once(db.php): failed to open stream: Operation not permitted in /in/pdH8j on line 2 Fatal error: require_once(): Failed opening required 'db.php' (include_path='.:') in /in/pdH8j on line 2
Process exited with code 255.

preferences:
182.63 ms | 403 KiB | 211 Q