3v4l.org

run code in 300+ PHP versions simultaneously
<?php function curl($url) { $options = Array( CURLOPT_RETURNTRANSFER => TRUE, // Setting cURL's option to return the webpage data CURLOPT_FOLLOWLOCATION => TRUE, // Setting cURL to follow 'location' HTTP headers CURLOPT_AUTOREFERER => TRUE, // Automatically set the referer where following 'location' HTTP headers CURLOPT_CONNECTTIMEOUT => 120, // Setting the amount of time (in seconds) before the request times out CURLOPT_TIMEOUT => 120, // Setting the maximum amount of time for cURL to execute queries CURLOPT_MAXREDIRS => 10, // Setting the maximum number of redirections to follow CURLOPT_USERAGENT => "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1a2pre) Gecko/2008073000 Shredder/3.0a2pre ThunderBrowse/3.2.1.8", // Setting the useragent CURLOPT_URL => $url, // Setting cURL's URL option with the $url variable passed into the function ); $ch = curl_init(); // Initialising cURL curl_setopt_array($ch, $options); // Setting cURL's options using the previously assigned array data in $options $data = curl_exec($ch); // Executing the cURL request and assigning the returned data to the $data variable curl_close($ch); // Closing cURL return $data; // Returning the data from the function } function regex_scrape($regex,$results_page){ preg_match_all($regex,$results_page,$match); return $match; } $continue = TRUE; $prices = array(); $url = "https://www.airbnb.de/s/Prague~Prague-1--Czech-Republic"; while ($continue == TRUE) { $results_page = curl($url); // Downloading the results page using our curl() funtion $prices2 = regex_scrape('/<span class=\"h3 price-amount\">(.*)span>/',$results_page); //PRINTING ARRAY SUM NOT WORKIN var_dump($prices2[0]); echo 'TOTAL: ' . array_sum(array_values($prices2[0])); $prices = array_merge($prices,$prices2[0]); if (strpos($results_page, "<li class=\"next next_page\">")) { $continue = FALSE; preg_match('/<li class="next next_page"><a target=".*" rel="next" href="(.*)"><i class="icon icon-caret-right">/',$results_page,$url); $url = 'https://www.airbnb.de' . $url[1]; } else { $continue = FALSE; // Setting $continue to FALSE if there's no 'Next' link } sleep(rand(0,1)); // Sleep for 3 to 5 seconds. Useful if not using proxies. We don't want to get into trouble. } ?>
Output for 7.2.0
Warning: Use of undefined constant CURLOPT_RETURNTRANSFER - assumed 'CURLOPT_RETURNTRANSFER' (this will throw an Error in a future version of PHP) in /in/eleo0 on line 4 Warning: Use of undefined constant CURLOPT_FOLLOWLOCATION - assumed 'CURLOPT_FOLLOWLOCATION' (this will throw an Error in a future version of PHP) in /in/eleo0 on line 5 Warning: Use of undefined constant CURLOPT_AUTOREFERER - assumed 'CURLOPT_AUTOREFERER' (this will throw an Error in a future version of PHP) in /in/eleo0 on line 6 Warning: Use of undefined constant CURLOPT_CONNECTTIMEOUT - assumed 'CURLOPT_CONNECTTIMEOUT' (this will throw an Error in a future version of PHP) in /in/eleo0 on line 7 Warning: Use of undefined constant CURLOPT_TIMEOUT - assumed 'CURLOPT_TIMEOUT' (this will throw an Error in a future version of PHP) in /in/eleo0 on line 8 Warning: Use of undefined constant CURLOPT_MAXREDIRS - assumed 'CURLOPT_MAXREDIRS' (this will throw an Error in a future version of PHP) in /in/eleo0 on line 9 Warning: Use of undefined constant CURLOPT_USERAGENT - assumed 'CURLOPT_USERAGENT' (this will throw an Error in a future version of PHP) in /in/eleo0 on line 10 Warning: Use of undefined constant CURLOPT_URL - assumed 'CURLOPT_URL' (this will throw an Error in a future version of PHP) in /in/eleo0 on line 11 Fatal error: Uncaught Error: Call to undefined function curl_init() in /in/eleo0:14 Stack trace: #0 /in/eleo0(33): curl('https://www.air...') #1 {main} thrown in /in/eleo0 on line 14
Process exited with code 255.
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.7
Notice: Use of undefined constant CURLOPT_RETURNTRANSFER - assumed 'CURLOPT_RETURNTRANSFER' in /in/eleo0 on line 4 Notice: Use of undefined constant CURLOPT_FOLLOWLOCATION - assumed 'CURLOPT_FOLLOWLOCATION' in /in/eleo0 on line 5 Notice: Use of undefined constant CURLOPT_AUTOREFERER - assumed 'CURLOPT_AUTOREFERER' in /in/eleo0 on line 6 Notice: Use of undefined constant CURLOPT_CONNECTTIMEOUT - assumed 'CURLOPT_CONNECTTIMEOUT' in /in/eleo0 on line 7 Notice: Use of undefined constant CURLOPT_TIMEOUT - assumed 'CURLOPT_TIMEOUT' in /in/eleo0 on line 8 Notice: Use of undefined constant CURLOPT_MAXREDIRS - assumed 'CURLOPT_MAXREDIRS' in /in/eleo0 on line 9 Notice: Use of undefined constant CURLOPT_USERAGENT - assumed 'CURLOPT_USERAGENT' in /in/eleo0 on line 10 Notice: Use of undefined constant CURLOPT_URL - assumed 'CURLOPT_URL' in /in/eleo0 on line 11 Fatal error: Uncaught Error: Call to undefined function curl_init() in /in/eleo0:14 Stack trace: #0 /in/eleo0(33): curl('https://www.air...') #1 {main} thrown in /in/eleo0 on line 14
Process exited with code 255.
Output for 5.0.0 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.24 - 5.5.35, 5.6.7 - 5.6.28
Notice: Use of undefined constant CURLOPT_RETURNTRANSFER - assumed 'CURLOPT_RETURNTRANSFER' in /in/eleo0 on line 4 Notice: Use of undefined constant CURLOPT_FOLLOWLOCATION - assumed 'CURLOPT_FOLLOWLOCATION' in /in/eleo0 on line 5 Notice: Use of undefined constant CURLOPT_AUTOREFERER - assumed 'CURLOPT_AUTOREFERER' in /in/eleo0 on line 6 Notice: Use of undefined constant CURLOPT_CONNECTTIMEOUT - assumed 'CURLOPT_CONNECTTIMEOUT' in /in/eleo0 on line 7 Notice: Use of undefined constant CURLOPT_TIMEOUT - assumed 'CURLOPT_TIMEOUT' in /in/eleo0 on line 8 Notice: Use of undefined constant CURLOPT_MAXREDIRS - assumed 'CURLOPT_MAXREDIRS' in /in/eleo0 on line 9 Notice: Use of undefined constant CURLOPT_USERAGENT - assumed 'CURLOPT_USERAGENT' in /in/eleo0 on line 10 Notice: Use of undefined constant CURLOPT_URL - assumed 'CURLOPT_URL' in /in/eleo0 on line 11 Fatal error: Call to undefined function curl_init() in /in/eleo0 on line 14
Process exited with code 255.
Output for 4.4.5 - 4.4.9
Notice: Use of undefined constant CURLOPT_RETURNTRANSFER - assumed 'CURLOPT_RETURNTRANSFER' in /in/eleo0 on line 4 Notice: Use of undefined constant CURLOPT_FOLLOWLOCATION - assumed 'CURLOPT_FOLLOWLOCATION' in /in/eleo0 on line 5 Notice: Use of undefined constant CURLOPT_AUTOREFERER - assumed 'CURLOPT_AUTOREFERER' in /in/eleo0 on line 6 Notice: Use of undefined constant CURLOPT_CONNECTTIMEOUT - assumed 'CURLOPT_CONNECTTIMEOUT' in /in/eleo0 on line 7 Notice: Use of undefined constant CURLOPT_TIMEOUT - assumed 'CURLOPT_TIMEOUT' in /in/eleo0 on line 8 Notice: Use of undefined constant CURLOPT_MAXREDIRS - assumed 'CURLOPT_MAXREDIRS' in /in/eleo0 on line 9 Notice: Use of undefined constant CURLOPT_USERAGENT - assumed 'CURLOPT_USERAGENT' in /in/eleo0 on line 10 Notice: Use of undefined constant CURLOPT_URL - assumed 'CURLOPT_URL' in /in/eleo0 on line 11 Fatal error: Call to undefined function: curl_init() in /in/eleo0 on line 14
Process exited with code 255.
Output for 4.3.2 - 4.3.11, 4.4.0 - 4.4.4
Notice: Use of undefined constant CURLOPT_RETURNTRANSFER - assumed 'CURLOPT_RETURNTRANSFER' in /in/eleo0 on line 4 Notice: Use of undefined constant CURLOPT_FOLLOWLOCATION - assumed 'CURLOPT_FOLLOWLOCATION' in /in/eleo0 on line 5 Notice: Use of undefined constant CURLOPT_AUTOREFERER - assumed 'CURLOPT_AUTOREFERER' in /in/eleo0 on line 6 Notice: Use of undefined constant CURLOPT_CONNECTTIMEOUT - assumed 'CURLOPT_CONNECTTIMEOUT' in /in/eleo0 on line 7 Notice: Use of undefined constant CURLOPT_TIMEOUT - assumed 'CURLOPT_TIMEOUT' in /in/eleo0 on line 8 Notice: Use of undefined constant CURLOPT_MAXREDIRS - assumed 'CURLOPT_MAXREDIRS' in /in/eleo0 on line 9 Notice: Use of undefined constant CURLOPT_USERAGENT - assumed 'CURLOPT_USERAGENT' in /in/eleo0 on line 10 Notice: Use of undefined constant CURLOPT_URL - assumed 'CURLOPT_URL' in /in/eleo0 on line 11 Fatal error: Call to undefined function: curl_init() in /in/eleo0 on line 14
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Notice: Use of undefined constant CURLOPT_RETURNTRANSFER - assumed 'CURLOPT_RETURNTRANSFER' in /in/eleo0 on line 4 Notice: Use of undefined constant CURLOPT_FOLLOWLOCATION - assumed 'CURLOPT_FOLLOWLOCATION' in /in/eleo0 on line 5 Notice: Use of undefined constant CURLOPT_AUTOREFERER - assumed 'CURLOPT_AUTOREFERER' in /in/eleo0 on line 6 Notice: Use of undefined constant CURLOPT_CONNECTTIMEOUT - assumed 'CURLOPT_CONNECTTIMEOUT' in /in/eleo0 on line 7 Notice: Use of undefined constant CURLOPT_TIMEOUT - assumed 'CURLOPT_TIMEOUT' in /in/eleo0 on line 8 Notice: Use of undefined constant CURLOPT_MAXREDIRS - assumed 'CURLOPT_MAXREDIRS' in /in/eleo0 on line 9 Notice: Use of undefined constant CURLOPT_USERAGENT - assumed 'CURLOPT_USERAGENT' in /in/eleo0 on line 10 Notice: Use of undefined constant CURLOPT_URL - assumed 'CURLOPT_URL' in /in/eleo0 on line 11 Fatal error: Call to undefined function: curl_init() in /in/eleo0 on line 14

preferences:
154.26 ms | 403 KiB | 175 Q