3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php chdir("/home/kolhozba/public_html/obmen/"); function action($nextUrl) { $curl = curl_init(); curl_setopt ($curl, CURLOPT_URL, $nextUrl); curl_setopt ($curl, CURLOPT_AUTOREFERER, true); // TRUE для автоматической установки поля Referer: в запросах, перенаправленных заголовком Location:. curl_setopt ($curl, CURLOPT_FOLLOWLOCATION, true); // TRUE для следования любому заголовку "Location: ", отправленному сервером в своем ответе (учтите, что это происходит рекурсивно, PHP будет следовать за всеми посылаемыми заголовками "Location: ", за исключением случая, когда установлена константа CURLOPT_MAXREDIRS). curl_setopt ($curl, CURLOPT_TIMEOUT, 10); // Сколько сек. ждать ответ сервра curl_setopt ($curl, CURLOPT_COOKIEFILE, 'cookie.txt'); curl_setopt ($curl, CURLOPT_COOKIEJAR, 'cookie.txt'); curl_setopt ($curl, CURLOPT_USERAGENT, "Opera/9.80 (J2ME/MIDP; Opera Mini/9.80 (S60; SymbOS; Opera Mobi/23.334; U; id) Presto/2.5.25 Version/10.54"); curl_setopt ($curl, CURLOPT_HEADER, true); // TRUE для включения заголовков в вывод. curl_setopt($curl, CURLINFO_HEADER_OUT, true); curl_setopt ($curl, CURLOPT_RETURNTRANSFER, true); // TRUE для возврата результата передачи в качестве строки из curl_exec() вместо прямого вывода в браузер. $out = curl_exec($curl); curl_close($curl); return $out; } $arr=file('list.txt'); for ($i=0;$i<count($arr);$i++) { $nextUrl=$arr[$i]; $hostUrl=parse_url($nextUrl); $hostUrl=$hostUrl["host"]; sleep(mt_rand(1,4)); action($nextUrl); $nextUrl='http://'.$hostUrl.'/converter'; sleep(mt_rand(1,4)); $dump=action($nextUrl); $dom = new DomDocument; @$dom->loadHTML($dump); $xpath = new DomXPath($dom); if ($xpath->evaluate("//div[@class='content']/div[@class='block']/div[2]/a/text()")->item(0)->nodeValue=='Обменять') { $xpath=$xpath->evaluate("//div[@class='content']/div[@class='block']/div[2]/a")->item(0)->getAttribute('href'); $nextUrl='http://'.$hostUrl.'/'.$xpath; sleep(mt_rand(1,4)); $dump=action($nextUrl); $dom = new DomDocument; @$dom->loadHTML($dump); $xpath = new DomXPath($dom); $xpath=$xpath->evaluate("//div[@style='text-align:center;']/div[@class='pt']/a")->item(0)->getAttribute('href'); $nextUrl='http://'.$hostUrl.'/'.substr($xpath, 6); sleep(mt_rand(1,4)); $dump=action($nextUrl); } else { $xpath=$xpath->evaluate("//div[@style='text-align:center;']/div[@class='pt']/a")->item(0)->getAttribute('href'); $nextUrl='http://'.$hostUrl.'/'.$xpath; sleep(mt_rand(1,4)); $dump=action($nextUrl); } } echo "Done"; ?>
Output for 7.0.0, 7.0.4 - 7.0.6, 7.1.0
Warning: chdir(): No such file or directory (errno 2) in /in/mEe1I on line 2 Warning: file(list.txt): failed to open stream: No such file or directory in /in/mEe1I on line 20 Notice: Undefined index: host in /in/mEe1I on line 25 Fatal error: Uncaught Error: Call to undefined function curl_init() in /in/mEe1I:5 Stack trace: #0 /in/mEe1I(27): action(NULL) #1 {main} thrown in /in/mEe1I on line 5
Process exited with code 255.
Output for 5.3.4, 5.3.6 - 5.3.7, 5.3.11 - 5.3.13, 5.3.16 - 5.3.17, 5.3.19, 5.3.21, 5.3.23 - 5.3.27, 5.4.0, 5.4.5 - 5.4.12, 5.4.14, 5.4.16, 5.4.18 - 5.4.20, 5.4.24, 5.4.26 - 5.4.35, 5.4.41 - 5.4.43, 5.5.25 - 5.5.27, 5.5.29, 5.5.32 - 5.5.33, 5.6.9 - 5.6.11, 5.6.13 - 5.6.14, 5.6.16, 5.6.18 - 5.6.21, 7.0.1 - 7.0.3, 7.0.14
Warning: chdir(): No such file or directory (errno 2) in /in/mEe1I on line 2 Warning: file(list.txt): failed to open stream: No such file or directory in /in/mEe1I on line 20 Notice: Undefined index: host in /in/mEe1I on line 25
Process exited with code 137.
Output for hhvm-3.12.0
Warning: No such file or directory (errno 2) in /in/mEe1I on line 2 Warning: No such file or directory in /in/mEe1I on line 20 Notice: Undefined index: host in /in/mEe1I on line 25
Process exited with code 137.
Output for hhvm-3.10.0

Process exited with code 153.
Output for 5.3.5, 5.3.8 - 5.3.10, 5.3.14 - 5.3.15, 5.3.18, 5.3.20, 5.3.22, 5.3.28 - 5.3.29, 5.4.1 - 5.4.4, 5.4.13, 5.4.15, 5.4.17, 5.4.21 - 5.4.23, 5.4.25, 5.4.36 - 5.4.40, 5.4.44 - 5.5.24, 5.5.28, 5.5.30 - 5.5.31, 5.5.34 - 5.6.8, 5.6.12, 5.6.15, 5.6.17
Warning: chdir(): No such file or directory (errno 2) in /in/mEe1I on line 2 Warning: file(list.txt): failed to open stream: No such file or directory in /in/mEe1I on line 20 Notice: Undefined index: host in /in/mEe1I on line 25 Fatal error: Call to undefined function curl_init() in /in/mEe1I on line 5
Process exited with code 255.
Output for 5.2.16 - 5.2.17
Warning: chdir(): No such file or directory (errno 2) in /in/mEe1I on line 2 Warning: file(list.txt): failed to open stream: No such file or directory in /in/mEe1I on line 20 Notice: Undefined index: host in /in/mEe1I on line 25 Fatal error: Call to undefined function curl_init() in /in/mEe1I on line 5
Process exited with code 255.
Output for 5.2.15
Warning: chdir(): No such file or directory (errno 2) in /in/mEe1I on line 2 Warning: file(list.txt): failed to open stream: No such file or directory in /in/mEe1I on line 20 Notice: Undefined index: host in /in/mEe1I on line 25
Process exited with code 137.