3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?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; });
based on kuLmD
Output for 5.3.0 - 7.1.0
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 4.4.2 - 4.4.9, 5.1.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.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.