3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $tsId = 'X1C77CF6EE730D2E88A284D7203D1B20F'; $cacheFileName = '/tmp/'.$tsId.'.xml'; $cacheTimeOut = 43200; // half a day $apiUrl = 'http://www.trustedshops.com/api/ratings/v1/'.$tsId.'.xml'; $xmlFound = false; if ($xml = simplexml_load_file($apiUrl)) { $xPath = "/shop/ratings/result[@name='average']"; $result = (float) $xml -> xpath($xPath); $avg = $result[0]->asXml(); $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 $avg;?> </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 5.2.6 - 5.6.28, 7.0.0 - 7.1.0
Warning: simplexml_load_file(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /in/ccdIW on line 11 Warning: simplexml_load_file(http://www.trustedshops.com/api/ratings/v1/X1C77CF6EE730D2E88A284D7203D1B20F.xml): failed to open stream: php_network_getaddresses: getaddrinfo failed: Name or service not known in /in/ccdIW on line 11 Warning: simplexml_load_file(): I/O warning : failed to load external entity "http://www.trustedshops.com/api/ratings/v1/X1C77CF6EE730D2E88A284D7203D1B20F.xml" in /in/ccdIW on line 11
Output for hhvm-3.10.0 - 3.12.0
Warning: Failed to open http://www.trustedshops.com/api/ratings/v1/X1C77CF6EE730D2E88A284D7203D1B20F.xml (Could not resolve host: www.trustedshops.com) in /in/ccdIW on line 11
Output for 5.1.0 - 5.2.5
Warning: simplexml_load_file(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /in/ccdIW on line 11 Warning: simplexml_load_file(http://www.trustedshops.com/api/ratings/v1/X1C77CF6EE730D2E88A284D7203D1B20F.xml): failed to open stream: Connection refused in /in/ccdIW on line 11 Warning: simplexml_load_file(): I/O warning : failed to load external entity "http://www.trustedshops.com/api/ratings/v1/X1C77CF6EE730D2E88A284D7203D1B20F.xml" in /in/ccdIW on line 11
Output for 5.0.3 - 5.0.5
Warning: simplexml_load_file(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /in/ccdIW on line 11 Warning: simplexml_load_file(http://www.trustedshops.com/api/ratings/v1/X1C77CF6EE730D2E88A284D7203D1B20F.xml): failed to open stream: Connection refused in /in/ccdIW on line 11 Warning: connection refusedI/O warning : failed to load external entity "http://www.trustedshops.com/api/ratings/v1/X1C77CF6EE730D2E88A284D7203D1B20F.xml" in /in/ccdIW on line 11
Output for 5.0.1 - 5.0.2
Warning: simplexml_load_file(): php_network_getaddresses: gethostbyname failed in /in/ccdIW on line 11 Warning: simplexml_load_file(http://www.trustedshops.com/api/ratings/v1/X1C77CF6EE730D2E88A284D7203D1B20F.xml): failed to open stream: Success in /in/ccdIW on line 11 Warning: connection refusedI/O warning : failed to load external entity "http://www.trustedshops.com/api/ratings/v1/X1C77CF6EE730D2E88A284D7203D1B20F.xml" in /in/ccdIW on line 11
Output for 5.0.0
Warning: simplexml_load_file(): php_network_getaddresses: gethostbyname failed in /in/ccdIW on line 11 Warning: simplexml_load_file(http://www.trustedshops.com/api/ratings/v1/X1C77CF6EE730D2E88A284D7203D1B20F.xml): failed to open stream: Bad file descriptor in /in/ccdIW on line 11 Warning: connection refusedI/O warning : failed to load external entity "http://www.trustedshops.com/api/ratings/v1/X1C77CF6EE730D2E88A284D7203D1B20F.xml" in /in/ccdIW on line 11
Output for 4.4.5 - 4.4.9
Fatal error: Call to undefined function: simplexml_load_file() in /in/ccdIW on line 11
Process exited with code 255.
Output for 4.3.2 - 4.4.4
Fatal error: Call to undefined function: simplexml_load_file() in /in/ccdIW on line 11
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Call to undefined function: simplexml_load_file() in /in/ccdIW on line 11