3v4l.org

run code in 300+ PHP versions simultaneously
<?php /* reset */ $tracking_code = $capcha1 = $capcha2 = $data = ''; /* Site 1 */ /* Sometimes this site gives an error so check before you run your request via normal website, the error comes up at $x("//span[@id='span1']/text()") via firebug console as the russian "База данных временно недоступна, повторите запрос позже." (database not accessible try again later) */ $tracking_code = 'CP021325078TR'; $url1 = 'http://www.russianpost.ru/tracking20/'; $capcha_url1 = 'http://www.russianpost.ru/tracking20/Code/Code.png.ashx'; //$postfields1 = '?BarCode='.$tracking_code.'&Code='.$capcha1; // check I haven't checked this in detail /* Site 2 */ $url2 = 'http://www1.ptt.gov.tr/tr/interaktif/kayitliposta-yd_yeniweb.php'; $capcha_url2 = 'http://www1.ptt.gov.tr/tr/interaktif/CaptchaSecurityImages.php?width=100&height=40&characters=5'; //$postfields2 = '?barkod='.$tracking_code.'&security_code'.$capcha2; // check I haven't checked this in detail. function fix_keys($array = null) { foreach ($array as $k => $val) { if(is_array($val)) { $array[$k] = fix_keys($val); } } return array_values($array); } function translit_Turkish($inputText) { $search = array('ç', 'Ç', 'ğ', 'Ğ', 'ı', 'i','I', 'İ', 'ö', 'Ö', 'ş', 'Ş', 'ü', 'Ü', 'Ãœ', 'Ä°', 'ö'); $replace = array('c', 'C', 'g', 'G', 'i', 'i','I', 'I', 'o', 'O', 's', 'S', 'u', 'U', 'U', 'I', 'o'); return str_replace($search, $replace, $inputText); } function clean_gunk($input) { $search = array( '&nbsp;',); return str_replace($search, '', $input); } function to_array($DomList) { $array = array(); foreach($DomList as $list) { $array[] = $list->nodeValue; } return $array; } function preview($results = null) { echo '<pre>'; print_r($results); echo '<br/>Node Values <br/>'; foreach($results as $result){ echo trim($result->nodeValue).'<br/>'; $array[] = $result; } echo '<br/><br/>'; if (isset($array)) { @print_r($array); // php error : not implemented yet. } } function get_capcha($url = null, $file) { $cookie = dirname(__FILE__).'/receita.txt.'; $fn = fopen($file,"w+"); $options = array ( CURLOPT_RETURNTRANSFER => TRUE, // dont need webpage data CURLOPT_BINARYTRANSFER => TRUE, // yes binary. CURLOPT_SSL_VERIFYPEER => FALSE, CURLOPT_SSL_VERIFYHOST => FALSE, CURLOPT_FOLLOWLOCATION => TRUE, CURLOPT_AUTOREFERER => TRUE, CURLOPT_NOPROGRESS => TRUE, CURLOPT_ENCODING => 'gzip', CURLOPT_CONNECTTIMEOUT => 240, CURLOPT_TIMEOUT => 240, CURLOPT_USERAGENT => 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6', // Setting the useragent CURLOPT_URL => $url, // URL that produces an image captcha. CURLOPT_COOKIE => 1, CURLOPT_COOKIESESSION => TRUE, CURLOPT_COOKIEFILE => $cookie, // do this more under the spell of the captcha CURLOPT_COOKIEJAR => $cookie, // this over the top make magic .. ah already said that; CURLOPT_FILE => $fn, ); $ch = curl_init(); curl_setopt_array($ch,$options); curl_exec($ch); curl_close($ch); fclose($fn); } if($_SERVER['REQUEST_METHOD'] == "POST") { //$capcha1 = trim($_POST['capchacode1']); //$capcha2 = $_POST['capchacode2']; $cnpj = $_POST ['cnpj']; $cnpj2 = $_POST ['cnpj2']; /* cURL rel stuff start */ $tracking_code = 'CP021325078TR'; $url = "http://www1.ptt.gov.tr/tr/interaktif/sonuc-yd.php"; $post_fields = 'barkod='.$tracking_code.'&security_code='.$cnpj; $agent = 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6'; $reffer = "http://www1.ptt.gov.tr/tr/interaktif/kayitliposta-yd_yeniweb.php"; $cookie = dirname(__FILE__).'/receita.txt.'; $header = array('Referer: xxx', 'Origin: '.$url, 'Content-Type: application/x-www-form-urlencoded', 'Connection: keep-alive', 'Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3', 'Cache-Control: max-age=0', 'Except:'); $options = array ( CURLOPT_URL => $url, CURLOPT_POST => 1, CURLOPT_POSTFIELDS => $post_fields, CURLOPT_USERAGENT => $agent, CURLOPT_REFERER => $reffer, CURLOPT_COOKIEFILE => $cookie, CURLOPT_COOKIEJAR => $cookie, CURLOPT_FOLLOWLOCATION => 1, CURLOPT_RETURNTRANSFER => 1, CURLOPT_HEADER => 0, ); $ch = curl_init(); curl_setopt_array($ch, $options); $response2 = curl_exec($ch); curl_close($ch); //$response1 <- should be from url1 //$response2 <- should be from url2 /*$url2 = "http://www.russianpost.ru/tracking20/CheckSubscription.js.aspx"; $post_fields2 = 'Id='.$tracking_code.'&Code='.$cnpj2.'&Language=Russian'; $reffer2 = "http://www.russianpost.ru/tracking20/"; // http://www.russianpost.ru/tracking20/CheckSubscription.js.aspx?Id=CP021325078TR&Code=84084&Language=Russian //http://www.russianpost.ru/tracking20/PostalOrderEventsForMail.js.aspx?Id=CP021325078TR&Code=84084&Language=Russian $options2 = array ( CURLOPT_URL => $url2, CURLOPT_POST => 1, CURLOPT_POSTFIELDS => $post_fields2, CURLOPT_USERAGENT => $agent, CURLOPT_REFERER => $reffer2, CURLOPT_COOKIEFILE => $cookie, CURLOPT_COOKIEJAR => $cookie, CURLOPT_FOLLOWLOCATION => 1, CURLOPT_RETURNTRANSFER => 1, CURLOPT_HEADER => 0, ); $ch2 = curl_init(); curl_setopt_array($ch2, $options2); $response1 = curl_exec($ch2); curl_close($ch2); /*S cURL rel stuff end */ print_r($response2); // for site 1 // query to get text data from page : http://www.russianpost.ru/tracking20/ // "//table[@id='tbl1']//tbody//tr//td/text()" /*$dom = new DOMDocument(); @$dom->loadHTML($response1); $xpath = new DOMXPATH($dom); $data1 = to_array($xpath->query("//table[@id='tbl1']//tbody//tr//td/text()")); // checked query via browser ok */ // for site 2 // query to get text data from page : http://www1.ptt.gov.tr/tr/interaktif/sonuc-yd.php // "(//table)[3]//tbody//tr//td/text()|(//table)[9]//tbody//tr//td/text()" //$remove = '<html xmlns="http://www.w3.org/1999/xhtml">'; //$response2 = str_replace($remove, '', $response2); $wr = fopen('temp.txt','w+'); fwrite($wr, $response2); fclose($wr); //$response2 = str_replace('&nbsp;', '', $response2); $response2 = iconv('iso-8859-9','utf-8', $response2); $response2 = clean_gunk(translit_Turkish($response2)); $dom = new DOMDocument(); @$dom->loadHTML($response2); $xpath = new DOMXPATH($dom); //preview($xpath2); //top part $data = to_array($xpath->query("(//table[3]//tr//text())")); //checked via browser ok. $data = fix_keys(array_filter($data, create_function('$a','return trim($a)!=="";'))); for($i=0; $i<count($data); $i=$i+5){ $row[] = trim(str_replace(' ','',$data[$i])).','.trim($data[$i+1]).','.trim($data[$i+2]).','.trim($data[$i+3]).','.trim($data[$i+4]); } var_dump($row); //bottom part $data2 = to_array($xpath->query("(//table[9]//tr//text())")); //checked via browser ok. $data2 = fix_keys(array_filter($data2, create_function('$a','return trim($a)!=="";'))); unset($data2[0]); unset($data2[1]); unset($data2[2]); $data2 = fix_keys($data2); for($i=0; $i<count($data2); $i=$i+3){ $row2[] = trim(str_replace(' ','',$data2[$i])).','.trim($data2[$i+1]).','.trim($data2[$i+2]); } var_dump($row2); //preview($data); // display $data1 and $data2 shouldn't be null if the curl returned the correct result pages. echo '<pre>'; //var_dump($data1); //var_dump($data1); //var_dump($data); } else { get_capcha ($capcha_url2, "capcha.jpg"); //get_capcha ($capcha_url1, "capcha2.jpg"); // And create the form that + image shows the input field CNPJ echo "<img src = 'capcha.jpg' />". "<img src = 'capcha2.jpg' />". '<form action = "'.htmlentities($_SERVER['PHP_SELF']).'" method = "POST"> captcha <input name = "cnpj"> <input name = "cnpj2"> <input type = "submit"> </ form> '; } ?>

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)
8.3.40.0150.00019.00
8.3.30.0160.00019.20
8.3.20.0040.00420.45
8.3.10.0080.00023.48
8.3.00.0080.00019.38
8.2.170.0040.01122.96
8.2.160.0080.00620.45
8.2.150.0060.00324.18
8.2.140.0130.00924.66
8.2.130.0040.00426.16
8.2.120.0070.00022.06
8.2.110.0130.01021.12
8.2.100.0070.00418.34
8.2.90.0000.00819.34
8.2.80.0030.00517.97
8.2.70.0030.00617.88
8.2.60.0050.00318.16
8.2.50.0030.00618.07
8.2.40.0040.00418.41
8.2.30.0000.00818.16
8.2.20.0030.00518.04
8.2.10.0040.00418.29
8.2.00.0040.00418.04
8.1.270.0040.00422.26
8.1.260.0090.00626.35
8.1.250.0040.00428.09
8.1.240.0100.00019.34
8.1.230.0040.00818.02
8.1.220.0050.00317.91
8.1.210.0040.00418.77
8.1.200.0070.00317.60
8.1.190.0030.00617.35
8.1.180.0040.00418.10
8.1.170.0050.00318.63
8.1.160.0080.00022.27
8.1.150.0030.00619.02
8.1.140.0070.00017.66
8.1.130.0030.00318.06
8.1.120.0000.00717.71
8.1.110.0040.00417.53
8.1.100.0000.00817.69
8.1.90.0030.00617.68
8.1.80.0040.00417.71
8.1.70.0000.00717.61
8.1.60.0030.00917.73
8.1.50.0000.00817.80
8.1.40.0030.00617.64
8.1.30.0060.00317.85
8.1.20.0040.00417.80
8.1.10.0060.00317.75
8.1.00.0000.00817.63
8.0.300.0000.00718.77
8.0.290.0000.00816.88
8.0.280.0040.00418.59
8.0.270.0040.00417.42
8.0.260.0030.00317.54
8.0.250.0030.00317.23
8.0.240.0030.00317.21
8.0.230.0070.00017.14
8.0.220.0050.00317.19
8.0.210.0030.00317.16
8.0.200.0040.00417.30
8.0.190.0030.00917.30
8.0.180.0030.00917.16
8.0.170.0100.00017.27
8.0.160.0030.00517.14
8.0.150.0050.00317.09
8.0.140.0040.00417.02
8.0.130.0000.00613.63
8.0.120.0030.00415.33
8.0.110.0040.00315.35
8.0.100.0040.00315.44
8.0.90.0070.00015.41
8.0.80.0050.00915.32
8.0.70.0010.00515.43
8.0.60.0010.00515.40
8.0.50.0070.00015.43
8.0.30.0100.00615.92
8.0.20.0070.00816.22
8.0.10.0030.00315.31
8.0.00.0090.00615.92
7.4.330.0030.00315.02
7.4.320.0080.00016.78
7.4.300.0000.00716.79
7.4.290.0000.00716.75
7.4.280.0000.00816.64
7.4.270.0030.00316.62
7.4.260.0030.00516.66
7.4.250.0040.00315.05
7.4.240.0010.00615.65
7.4.230.0030.00315.09
7.4.220.0090.00414.99
7.4.210.0040.00815.18
7.4.200.0040.00314.92
7.4.190.0060.00013.39
7.4.180.0050.00013.54
7.4.160.0070.00315.10
7.4.150.0020.01015.41
7.4.140.0080.00916.38
7.4.130.0070.00915.64
7.4.120.0100.00715.65
7.4.110.0020.01015.02
7.4.100.0050.00714.99
7.4.90.0120.00215.07
7.4.80.0090.00316.42
7.4.70.0070.00715.49
7.4.60.0110.00515.39
7.4.50.0080.00415.38
7.4.40.0060.01115.42
7.4.30.0120.00214.79
7.4.20.0070.00714.84
7.4.10.0080.00814.85
7.4.00.0040.00915.09
7.3.330.0000.00513.34
7.3.320.0060.00013.64
7.3.310.0040.00315.15
7.3.300.0020.00514.91
7.3.290.0040.00915.79
7.3.280.0110.00315.83
7.3.270.0060.00715.37
7.3.260.0070.00514.92
7.3.250.0070.00715.63
7.3.240.0030.01015.15
7.3.230.0050.00715.14
7.3.220.0030.00313.20
7.3.210.0090.00314.98
7.3.200.0080.00514.89
7.3.190.0120.00315.38
7.3.180.0100.00515.37
7.3.170.0060.01015.32
7.3.160.0120.00515.30
7.3.150.0100.00614.85
7.3.140.0050.01014.83
7.3.130.0060.01014.95
7.3.120.0060.01114.86
7.3.110.0080.00914.89
7.3.100.0090.00614.86
7.3.90.0050.00915.04
7.3.80.0080.00614.86
7.3.70.0040.00914.75
7.3.60.0100.00714.85
7.3.50.0070.00814.90
7.3.40.0030.01014.95
7.3.30.0060.00814.80
7.3.20.0070.00715.95
7.3.10.0090.00616.19
7.3.00.0080.01016.09
7.2.340.0090.00213.53
7.2.330.0100.00615.03
7.2.320.0090.00715.13
7.2.310.0080.01115.47
7.2.300.0080.01015.51
7.2.290.0100.00815.57
7.2.280.0150.00214.82
7.2.270.0040.01314.92
7.2.260.0110.00815.03
7.2.250.0080.01015.03
7.2.240.0120.00714.97
7.2.230.0090.00814.94
7.2.220.0090.00914.95
7.2.210.0110.00715.01
7.2.200.0080.01215.10
7.2.190.0130.00715.05
7.2.180.0060.00915.19
7.2.170.0120.00415.11
7.2.160.0070.01014.97
7.2.150.0130.00216.28
7.2.140.0110.00416.15
7.2.130.0140.00516.42
7.2.120.0110.00516.40
7.2.110.0070.01116.42
7.2.100.0110.00916.38
7.2.90.0110.00716.45
7.2.80.0100.00716.43
7.2.70.0090.00916.46
7.2.60.0080.00516.46
7.2.50.0080.00816.37
7.2.40.0280.01016.36
7.2.30.0100.00816.47
7.2.20.0060.00916.39
7.2.10.0100.00716.30
7.2.00.0090.00816.50
7.1.330.0170.00615.24
7.1.320.0100.00915.31
7.1.310.0070.01315.14
7.1.300.0130.00615.38
7.1.290.0100.00715.31
7.1.280.0120.00615.25
7.1.270.0110.00715.33
7.1.260.0080.01015.29
7.1.250.0150.00615.42
7.1.240.0110.00815.35
7.1.230.0110.00815.28
7.1.220.0070.01215.44
7.1.210.0120.00815.24
7.1.200.0120.00615.52
7.1.190.0120.00415.21
7.1.180.0100.00815.31
7.1.170.0100.00715.26
7.1.160.0140.00415.31
7.1.150.0120.00615.31
7.1.140.0090.00915.31
7.1.130.0100.00915.20
7.1.120.0120.00815.31
7.1.110.0130.00815.37
7.1.100.0080.01015.21
7.1.90.0110.00515.29
7.1.80.0110.00515.28
7.1.70.0140.00515.84
7.1.60.0110.00916.16
7.1.50.0140.00720.23
7.1.40.0110.00715.17
7.1.30.0120.00715.24
7.1.20.0110.00815.20
7.1.10.0100.00815.24
7.1.00.0080.02617.04
7.0.330.0120.00615.15
7.0.320.0100.00915.07
7.0.310.0110.00714.93
7.0.300.0100.00814.98
7.0.290.0100.00715.01
7.0.280.0090.00515.01
7.0.270.0150.00315.09
7.0.260.0120.00615.00
7.0.250.0110.00715.12
7.0.240.0130.00414.96
7.0.230.0090.00815.06
7.0.220.0270.00815.14
7.0.210.0090.00814.97
7.0.200.0090.00515.58
7.0.190.0100.00715.02
7.0.180.0110.00815.09
7.0.170.0160.00715.00
7.0.160.0110.00715.03
7.0.150.0100.00615.05
7.0.140.0110.02016.80
7.0.130.0120.00614.95
7.0.120.0100.01014.88
7.0.110.0090.01015.06
7.0.100.0190.02516.22
7.0.90.0180.02516.24
7.0.80.0240.02116.71
7.0.70.0100.02716.24
7.0.60.0110.02216.38
7.0.50.0250.01916.41
7.0.40.0120.02615.83
7.0.30.0140.02415.84
7.0.20.0120.02415.79
7.0.10.0100.02815.75
7.0.00.0150.01915.72
5.6.400.0150.00614.44
5.6.390.0100.00914.51
5.6.380.0160.00714.55
5.6.370.0120.00714.57
5.6.360.0110.00914.50
5.6.350.0060.01214.45
5.6.340.0090.00714.71
5.6.330.0110.00814.52
5.6.320.0140.00614.54
5.6.310.0140.00514.34
5.6.300.0080.01114.27
5.6.290.0120.00714.38
5.6.280.0080.02615.97
5.6.270.0120.00714.58
5.6.260.0090.00814.52
5.6.250.0130.02416.03
5.6.240.0120.02416.03
5.6.230.0110.01916.05
5.6.220.0110.02216.05
5.6.210.0160.02115.99
5.6.200.0100.02316.13
5.6.190.0090.02616.13
5.6.180.0110.01916.09
5.6.170.0130.02116.20
5.6.160.0120.02516.09
5.6.150.0090.02716.26
5.6.140.0110.02516.14
5.6.130.0090.02816.04
5.6.120.0140.02016.16
5.6.110.0090.03016.11
5.6.100.0130.02316.08
5.6.90.0100.02116.02
5.6.80.0110.01715.90
5.6.70.0100.02515.97
5.6.60.0120.02115.95
5.6.50.0090.02615.90
5.6.40.0080.02715.90
5.6.30.0100.02415.86
5.6.20.0110.02515.90
5.6.10.0060.02515.95
5.6.00.0140.02115.86
5.5.380.0150.02315.98
5.5.370.0120.02515.99
5.5.360.0110.02315.93
5.5.350.0070.03015.92
5.5.340.0100.02016.10
5.5.330.0100.02116.15
5.5.320.0120.02415.97
5.5.310.0120.02116.17
5.5.300.0100.02815.96
5.5.290.0110.02516.08
5.5.280.0080.02716.10
5.5.270.0120.02616.12
5.5.260.0100.02416.11
5.5.250.0110.02216.11
5.5.240.0090.02315.80
5.5.230.0100.02215.84
5.5.220.0110.02415.79
5.5.210.0070.02815.85
5.5.200.0120.01415.82
5.5.190.0090.02015.93
5.5.180.0150.02115.72
5.5.170.0090.01114.32
5.5.160.0110.02215.72
5.5.150.0060.02615.80
5.5.140.0060.02915.77
5.5.130.0100.02515.86
5.5.120.0140.02215.79
5.5.110.0100.02415.78
5.5.100.0080.02615.75
5.5.90.0080.02615.83
5.5.80.0080.02815.84
5.5.70.0090.02615.65
5.5.60.0110.02515.88
5.5.50.0120.02415.75
5.5.40.0100.02515.72
5.5.30.0130.02115.75
5.5.20.0130.02415.83
5.5.10.0130.02215.78
5.5.00.0060.02715.69
5.4.450.0080.02713.92
5.4.440.0090.01813.93
5.4.430.0130.02014.10
5.4.420.0100.02413.98
5.4.410.0130.02013.95
5.4.400.0110.02313.91
5.4.390.0080.01913.94
5.4.380.0090.02213.81
5.4.370.0090.01713.97
5.4.360.0060.02613.95
5.4.350.0080.01613.87
5.4.340.0070.02613.92
5.4.330.0100.00412.22
5.4.320.0090.02014.05
5.4.310.0120.02014.01
5.4.300.0090.02314.05
5.4.290.0140.01913.90
5.4.280.0110.01613.96
5.4.270.0100.02213.87
5.4.260.0080.02613.83
5.4.250.0090.02113.87
5.4.240.0130.01514.00
5.4.230.0130.02013.83
5.4.220.0060.02313.89
5.4.210.0120.01913.84
5.4.200.0050.02413.89
5.4.190.0100.02213.85
5.4.180.0120.02013.86
5.4.170.0110.01613.87
5.4.160.0110.01813.85
5.4.150.0120.02113.88
5.4.140.0080.02213.33
5.4.130.0060.02313.29
5.4.120.0080.02313.29
5.4.110.0080.02113.35
5.4.100.0080.02413.28
5.4.90.0070.02513.34
5.4.80.0070.01813.34
5.4.70.0080.02313.28
5.4.60.0080.01913.35
5.4.50.0110.01613.36
5.4.40.0080.02313.38
5.4.30.0090.02013.37
5.4.20.0070.02113.29
5.4.10.0070.02213.22
5.4.00.0080.02213.00

preferences:
49.22 ms | 400 KiB | 5 Q