3v4l.org

run code in 300+ PHP versions simultaneously
<?php use Guzzle\Http\Client; use Guzzle\Http\Exception\BadResponseException; require __DIR__ . '/../helper/main.php'; $app->get('/get', function () use ($app) { $url = $app->request()->params('url'); if(filter_var($url, FILTER_VALIDATE_URL) === false){ $app->halt(422, 'Url is not valid'); } $m = new Mongo(); $db = $m->selectDB('rss'); $collection = new MongoCollection($db, 'rss'); $results = $collection->find(array('url' => $url))->sort(array('date' => -1))->limit(1); $result = array_values(iterator_to_array($results)); if(isset($result[0])){ $rss = $result[0]; $date = new DateTime(date('Y-m-d H:i:s', $rss['date']->sec)); $now = new DateTime(); $now->sub(new DateInterval('PT10M')); if($now < $date){ header('Content-Type: application/json'); $rss = preparerss($rss); echo json_encode($rss); exit; } } $client = new Client(); $link = 'https://feeddetect.p.mashape.com/page/findrss/?url=' . urlencode($url); $headers = array('X-Mashape-Key' => 'MlSBGJGKZHmshugjADdPSknL2LkIp1RofQLjsnRtNgJVazPAT4'); $request = $client->get($link, $headers); try { $response = $client->send($request); } catch (BadResponseException $e) { $error = 'The following exceptions were encountered: '. $e->getMessage(); $app->halt(500, $error); } $rss = $response->json(); $rss['date'] = new MongoDate(); $db->rss->insert($rss); header('Content-Type: application/json'); $rss = prepareRss($rss); echo json_encode($rss); exit; });
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.6
Warning: require(): open_basedir restriction in effect. File(/in/../helper/main.php) is not within the allowed path(s): (/tmp:/in:/etc) in /in/EdnLX on line 6 Warning: require(/in/../helper/main.php): Failed to open stream: Operation not permitted in /in/EdnLX on line 6 Fatal error: Uncaught Error: Failed opening required '/in/../helper/main.php' (include_path='.:') in /in/EdnLX:6 Stack trace: #0 {main} thrown in /in/EdnLX on line 6
Process exited with code 255.
Output for 8.0.13
Warning: require(/in/../helper/main.php): Failed to open stream: No such file or directory in /in/EdnLX on line 6 Fatal error: Uncaught Error: Failed opening required '/in/../helper/main.php' (include_path='.:') in /in/EdnLX:6 Stack trace: #0 {main} thrown in /in/EdnLX on line 6
Process exited with code 255.
Output for 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 7.3.32 - 7.3.33, 7.4.33
Warning: require(/in/../helper/main.php): failed to open stream: No such file or directory in /in/EdnLX on line 6 Fatal error: require(): Failed opening required '/in/../helper/main.php' (include_path='.:') in /in/EdnLX on line 6
Process exited with code 255.
Output for 5.5.0 - 5.5.38, 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: require(): open_basedir restriction in effect. File(/in/../helper/main.php) is not within the allowed path(s): (/tmp:/in:/etc) in /in/EdnLX on line 6 Warning: require(/in/../helper/main.php): failed to open stream: Operation not permitted in /in/EdnLX on line 6 Fatal error: require(): Failed opening required '/in/../helper/main.php' (include_path='.:') in /in/EdnLX on line 6
Process exited with code 255.
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17
Parse error: syntax error, unexpected T_STRING, expecting T_CONSTANT_ENCAPSED_STRING or '(' in /in/EdnLX on line 3
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1, 5.0.0 - 5.0.5
Parse error: parse error, unexpected T_STRING, expecting T_CONSTANT_ENCAPSED_STRING or '(' in /in/EdnLX on line 3
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_CONSTANT_ENCAPSED_STRING' or `'('' in /in/EdnLX on line 3
Process exited with code 255.

preferences:
319.75 ms | 401 KiB | 459 Q