3v4l.org

run code in 300+ PHP versions simultaneously
<?php class scraper { public static $response; public static $dom; // randomize useragent string public static function get_useragent() { $ua = array( "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.89 Safari/537.1", "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:14.0) Gecko/20100101 Firefox/14.0.1", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_1) AppleWebKit/536.25 (KHTML, like Gecko) Version/6.0 Safari/536.25", "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)", "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:15.0) Gecko/20100101 Firefox/15.0.1" ); shuffle($ua); $x = array_rand($ua); return $ua[$x]; } // download using curl public static function data_download($_url) { if(!function_exists('curl_init')) { die('Sorry cURL is not installed!'); } try { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $_url); curl_setopt($ch, CURLOPT_REFERER, "http://www.google.com/"); curl_setopt($ch, CURLOPT_USERAGENT, self::get_useragent()); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_TIMEOUT, 30); $output = curl_exec($ch); curl_close($ch); return $output; } catch(Zend_Exception $e) { echo 'Caught Exception: ' . get_class($e) . "\n"; echo 'Message: ' . $e->getMessage() . "\n"; } } public static function data_cache($url) { $cache = Zend_Registry::get('cache'); $cache_id = md5($url); try { if(!$response = $cache->load($cache_id)) { // delay execution for a few seconds at random //sleep(rand(5, 15)); $response = trim(self::data_download($url)); $response = $cache->save($response, $cache_id); $response = $cache->load($cache_id); self::$response = $response; } else { $response = $cache->load($cache_id); self::$response = $response; } } catch(Zend_Exception $e) { echo 'Caught Exception: ' . get_class($e) . "\n"; echo 'Message: ' . $e->getMessage() . "\n"; } } public static function query_css($query) { $html = self::$response; $dom = new Zend_Dom_Query($html); $results = $dom->query($query); return $results; } public static function query_xpath($query) { $html = self::$response; $dom = new Zend_Dom_Query($html); $results = $dom->queryXpath($query); ; return $results; } public static function load_pq_dom() { try { $html = self::$response; $dom = phpQuery::newDocumentHTML($html); self::$dom = $dom; } catch(Zend_Exception $e) { echo 'Caught Exception: ' . get_class($e) . "\n"; echo 'Message: ' . $e->getMessage() . "\n"; } } public static function query_pq($query) { self::load_pq_dom(); $dom = self::$dom; $dom = $dom->find($query); $result = $dom->html(); return $result; } public static function parse_table($query, $_key, $_value) { self::load_pq_dom(); $dom = self::$dom; foreach(pq($query) as $block) { $key = trim(pq($_key, $block)->text()); $value = trim(pq($_value, $block)->text()); $array[$key] = $value; } return $array; } public static function parse_list($query) { self::load_pq_dom(); $dom = self::$dom; foreach(pq($query) as $block) { $list_item = trim(pq('ul li', $block)->text()); $array[] = $list_item; } return $array; } public static function parse_options($query) { self::load_pq_dom(); $dom = self::$dom; foreach(pq($query) as $block) { $list_item = trim(pq('option', $block)->text()); $array[] = $list_item; } return $array; } public static function parse_links($query) { $dom = self::$dom; $a = self::query_css($query); foreach($a as $href) { $links[] = $href->getAttribute('href'); } return $links; } public static function setup_database($host, $db_name, $user, $password) { Zend_Loader_Autoloader::getInstance()->registerNamespace("RedBean_"); R::setup("mysql:host={$host}; dbname={$db_name}", $user, $password); } }

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
7.4.10.0130.00314.81
7.4.00.0120.00414.97
7.3.130.0060.01215.01
7.3.120.0140.00314.73
7.3.110.0120.00614.46
7.3.100.0040.01114.37
7.3.90.0040.00814.92
7.3.80.0030.01214.87
7.3.70.0030.01014.59
7.3.60.0040.01114.73
7.3.50.0090.00614.52
7.3.40.0030.00714.54
7.3.30.0050.01114.64
7.3.20.0090.00715.58
7.3.10.0090.00715.52
7.3.00.0140.00715.64
7.2.260.0040.01414.71
7.2.250.0030.01314.67
7.2.240.0040.01214.86
7.2.230.0040.01115.14
7.2.220.0130.00014.71
7.2.210.0060.00914.69
7.2.200.0040.01114.80
7.2.190.0000.01214.91
7.2.180.0030.01314.94
7.2.170.0100.00914.77
7.2.160.0060.01014.84
7.2.150.0110.00515.73
7.2.140.0030.01215.80
7.2.130.0060.00815.66
7.2.120.0070.01115.72
7.2.110.0120.00815.82
7.2.100.0510.00515.71
7.2.90.0090.01215.80
7.2.80.0110.00515.73
7.2.70.0060.01115.73
7.2.60.0080.01115.72
7.2.50.0110.00915.82
7.2.40.0090.00615.82
7.2.30.0050.00915.94
7.2.20.0130.00615.83
7.2.10.0040.01315.81
7.2.00.0120.00815.83
7.1.330.0030.01315.46
7.1.320.0100.00315.76
7.1.310.0000.01415.67
7.1.300.0050.00815.45
7.1.290.0060.00615.61
7.1.280.0060.01414.70
7.1.270.0120.00214.76
7.1.260.0120.00714.63
7.1.250.0050.00714.77
7.1.240.0100.00315.32
7.1.230.0110.00315.33
7.1.220.0100.00315.71
7.1.210.0080.00415.52
7.1.200.0060.01015.66
7.1.190.0060.00615.68
7.1.180.0100.00315.41
7.1.170.0070.00415.62
7.1.160.0120.00315.50
7.1.150.0060.00915.77
7.1.140.0090.00615.34
7.1.130.0100.00015.75
7.1.120.0040.00415.55
7.1.110.0030.00915.54
7.1.100.0140.00015.75
7.1.90.0060.00615.59
7.1.80.0060.00615.33
7.1.70.0040.01115.50
7.1.60.0060.00915.56
7.1.50.0100.00615.76
7.1.40.0030.01215.55
7.1.30.0060.00615.63
7.1.20.0070.00715.62
7.1.10.0130.00315.56
7.1.00.0030.00715.70

preferences:
34.26 ms | 401 KiB | 5 Q