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 git.master, git.master_jit, rfc.property-hooks
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.

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
51.66 ms | 402 KiB | 8 Q