3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php /* Install this pear extention on linux by doing: $ pear channel-discover phpquery-pear.appspot.com $ pear install phpquery/phpQuery */ require('phpQuery.php'); /** * Gets the server that a player has joined * @param string $username The username of the player * @return array An array that consists of: success, title, url and errorCode */ $username = "SoL0vex" ; function getJoinedServer ($username) { $curl = curl_init("http://battlelog.battlefield.com/bf3/user/$username"); curl_setopt($curl, CURLOPT_FAILONERROR, true); curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($curl, CURLOPT_ENCODING, 'gzip'); curl_setopt($curl, CURLOPT_TIMEOUT, 30); $doc = phpQuery::newDocument(curl_exec($curl)); phpQuery::selectDocument($doc); $li = pq('.common-playing-link a'); if (pq($li)->attr('href')) { return array('success' => true, 'title' => pq($li)->attr('title'), 'url' => 'http://battlelog.battlefield.com' . pq($li)->attr('href')); } else { return array('success' => false, 'errorCode' => 1); } curl_close($curl); } // Measure time $mtime = microtime(); $mtime = explode(' ',$mtime); $mtime = $mtime[1] + $mtime[0]; $starttime = $mtime; // Get joined server $result = getJoinedServer((isset($_GET['user']) ? $_GET['user'] : 'diegorod')); if($result['success']) { echo "<a href='${result['url']}'>${result['title']}</a>"; } elseif ($result['errorCode'] === 1) { echo 'User not playing'; } // Stop measuring time $mtime = microtime(); $mtime = explode(' ',$mtime); $mtime = $mtime[1] + $mtime[0]; $endtime = $mtime; $totaltime = ($endtime - $starttime); // Output execution time echo '<br>This page was created in '.$totaltime.' seconds'; ?>
based on TvTBX
Output for 7.1.25 - 7.3.1
Warning: require(): open_basedir restriction in effect. File(phpQuery.php) is not within the allowed path(s): (/tmp:/in:/etc) in /in/8r7rg on line 6 Warning: require(phpQuery.php): failed to open stream: Operation not permitted in /in/8r7rg on line 6 Fatal error: require(): Failed opening required 'phpQuery.php' (include_path='.:') in /in/8r7rg on line 6
Process exited with code 255.
Output for 5.5.0 - 7.1.10
Warning: require(phpQuery.php): failed to open stream: No such file or directory in /in/8r7rg on line 6 Fatal error: require(): Failed opening required 'phpQuery.php' (include_path='.:') in /in/8r7rg on line 6
Process exited with code 255.