3v4l.org

run code in 300+ PHP versions simultaneously
<?php $tsId = 'XACCB84E44344C2EEB8714B3210DE2907'; $cacheFileName = $tsId.'.xml'; $cacheTimeOut = 43200; // half a day $apiUrl = 'http://www.trustedshops.com/api/ratings/v1/'.$tsId.'.xml'; $xmlFound = false;// check if cached version exists if (!cachecheck($cacheFileName, $cacheTimeOut)) { // load fresh from API $ch = curl_init(); curl_setopt($ch, CURLOPT_HEADER, false); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POST, false); curl_setopt($ch, CURLOPT_URL, $apiUrl); $output = curl_exec($ch); curl_close($ch); // Write the contents back to the file // Make sure you can write to file's destination file_put_contents($cacheFileName, $output);} if ($xml = simplexml_load_file($cacheFileName)) { $xPath = "/shop/ratings/result[@name='average']"; $result = (float) $xml -> xpath($xPath)[0]; $max = "5.00"; $count = $xml->ratings["amount"]; $shopName = $xml->name; $xmlFound = true;}if ($xmlFound) { ?> <a href="http://www.trustedshops.eu/seller-rating/">Trusted Shops seller rating</a>:<span xmlns:v="http://rdf.data-vocabulary.org/#" typeof="v:Review-aggregate"> <span rel="v:rating"><span property="v:value"><?php echo $result;?> </span> </span> / <span property="v:best"><?php echo $max;?> </span> of <span property="v:count"><?php echo $count;?> </span> <a href="https://www.trustedshops.de/bewertung/info_<?php echo $tsId?>.html" title="<?php echo $shopName;?> bewertungen"> <?php echo $shopName;?> ratings</a> </span> <?php } function cachecheck($filename_cache, $timeout = 10800) { if (file_exists($filename_cache) && time() - filemtime($filename_cache) < $timeout) { return true; } return false; }
Output for 7.1.25 - 7.1.33, 7.2.0 - 7.2.25, 7.3.0 - 7.3.12, 7.4.0
Warning: file_exists(): open_basedir restriction in effect. File(XACCB84E44344C2EEB8714B3210DE2907.xml) is not within the allowed path(s): (/tmp:/in:/etc) in /in/aCUZc on line 33 Fatal error: Uncaught Error: Call to undefined function curl_init() in /in/aCUZc:9 Stack trace: #0 {main} thrown in /in/aCUZc on line 9
Process exited with code 255.
Output for 7.1.20
Warning: file_exists(): open_basedir restriction in effect. File(XACCB84E44344C2EEB8714B3210DE2907.xml) is not within the allowed path(s): (/tmp:/in) in /in/aCUZc on line 33 Fatal error: Uncaught Error: Call to undefined function curl_init() in /in/aCUZc:9 Stack trace: #0 {main} thrown in /in/aCUZc on line 9
Process exited with code 255.
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.7
Fatal error: Uncaught Error: Call to undefined function curl_init() in /in/aCUZc:9 Stack trace: #0 {main} thrown in /in/aCUZc on line 9
Process exited with code 255.
Output for 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.28
Fatal error: Call to undefined function curl_init() in /in/aCUZc on line 9
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, 5.3.0 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/aCUZc on line 21
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 '[' in /in/aCUZc on line 21
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/aCUZc on line 21
Process exited with code 255.

preferences:
217.18 ms | 401 KiB | 262 Q