3v4l.org

run code in 300+ PHP versions simultaneously
<?php function get_web_page( $url ) { $user_agent='Mozilla/5.0 (Windows NT 6.1; rv:8.0) Gecko/20100101 Firefox/8.0'; $options = array( CURLOPT_CUSTOMREQUEST =>"GET", //set request type post or get CURLOPT_POST =>false, //set to GET CURLOPT_USERAGENT => $user_agent, //set user agent CURLOPT_COOKIEFILE =>"cookie.txt", //set cookie file CURLOPT_COOKIEJAR =>"cookie.txt", //set cookie jar CURLOPT_RETURNTRANSFER => true, // return web page CURLOPT_HEADER => false, // don't return headers CURLOPT_FOLLOWLOCATION => true, // follow redirects CURLOPT_ENCODING => "", // handle all encodings CURLOPT_AUTOREFERER => true, // set referer on redirect CURLOPT_CONNECTTIMEOUT => 120, // timeout on connect CURLOPT_TIMEOUT => 120, // timeout on response CURLOPT_MAXREDIRS => 10, // stop after 10 redirects ); $ch = curl_init( $url ); curl_setopt_array( $ch, $options ); $content = curl_exec( $ch ); $err = curl_errno( $ch ); $errmsg = curl_error( $ch ); $header = curl_getinfo( $ch ); curl_close( $ch ); $header['errno'] = $err; $header['errmsg'] = $errmsg; $header['content'] = $content; return $header; } $result = get_web_page( "www.kompas.com" ); if ( $result['errno'] != 0 ) { echo "error: bad url, timeout, redirect loop ..."; } if ( $result['http_code'] != 200 ) { echo "... error: no page, no permissions, no service ..."; } echo $page = $result['content']; ?>
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.28, 8.4.1 - 8.4.14, 8.5.0 - 8.5.1
Fatal error: Uncaught Error: Undefined constant "CURLOPT_CUSTOMREQUEST" in /in/pdRdU:10 Stack trace: #0 /in/pdRdU(40): get_web_page('www.kompas.com') #1 {main} thrown in /in/pdRdU on line 10
Process exited with code 255.
Output for 8.4.15
/bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.35' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.34' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15)
Process exited with code 1.
Output for 7.2.0 - 7.2.34, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
Warning: Use of undefined constant CURLOPT_CUSTOMREQUEST - assumed 'CURLOPT_CUSTOMREQUEST' (this will throw an Error in a future version of PHP) in /in/pdRdU on line 10 Warning: Use of undefined constant CURLOPT_POST - assumed 'CURLOPT_POST' (this will throw an Error in a future version of PHP) in /in/pdRdU on line 11 Warning: Use of undefined constant CURLOPT_USERAGENT - assumed 'CURLOPT_USERAGENT' (this will throw an Error in a future version of PHP) in /in/pdRdU on line 12 Warning: Use of undefined constant CURLOPT_COOKIEFILE - assumed 'CURLOPT_COOKIEFILE' (this will throw an Error in a future version of PHP) in /in/pdRdU on line 13 Warning: Use of undefined constant CURLOPT_COOKIEJAR - assumed 'CURLOPT_COOKIEJAR' (this will throw an Error in a future version of PHP) in /in/pdRdU on line 14 Warning: Use of undefined constant CURLOPT_RETURNTRANSFER - assumed 'CURLOPT_RETURNTRANSFER' (this will throw an Error in a future version of PHP) in /in/pdRdU on line 15 Warning: Use of undefined constant CURLOPT_HEADER - assumed 'CURLOPT_HEADER' (this will throw an Error in a future version of PHP) in /in/pdRdU on line 16 Warning: Use of undefined constant CURLOPT_FOLLOWLOCATION - assumed 'CURLOPT_FOLLOWLOCATION' (this will throw an Error in a future version of PHP) in /in/pdRdU on line 17 Warning: Use of undefined constant CURLOPT_ENCODING - assumed 'CURLOPT_ENCODING' (this will throw an Error in a future version of PHP) in /in/pdRdU on line 18 Warning: Use of undefined constant CURLOPT_AUTOREFERER - assumed 'CURLOPT_AUTOREFERER' (this will throw an Error in a future version of PHP) in /in/pdRdU on line 19 Warning: Use of undefined constant CURLOPT_CONNECTTIMEOUT - assumed 'CURLOPT_CONNECTTIMEOUT' (this will throw an Error in a future version of PHP) in /in/pdRdU on line 20 Warning: Use of undefined constant CURLOPT_TIMEOUT - assumed 'CURLOPT_TIMEOUT' (this will throw an Error in a future version of PHP) in /in/pdRdU on line 21 Warning: Use of undefined constant CURLOPT_MAXREDIRS - assumed 'CURLOPT_MAXREDIRS' (this will throw an Error in a future version of PHP) in /in/pdRdU on line 22 Fatal error: Uncaught Error: Call to undefined function curl_init() in /in/pdRdU:25 Stack trace: #0 /in/pdRdU(40): get_web_page('www.kompas.com') #1 {main} thrown in /in/pdRdU on line 25
Process exited with code 255.
Output for 7.0.0 - 7.0.33, 7.1.0 - 7.1.33
Notice: Use of undefined constant CURLOPT_CUSTOMREQUEST - assumed 'CURLOPT_CUSTOMREQUEST' in /in/pdRdU on line 10 Notice: Use of undefined constant CURLOPT_POST - assumed 'CURLOPT_POST' in /in/pdRdU on line 11 Notice: Use of undefined constant CURLOPT_USERAGENT - assumed 'CURLOPT_USERAGENT' in /in/pdRdU on line 12 Notice: Use of undefined constant CURLOPT_COOKIEFILE - assumed 'CURLOPT_COOKIEFILE' in /in/pdRdU on line 13 Notice: Use of undefined constant CURLOPT_COOKIEJAR - assumed 'CURLOPT_COOKIEJAR' in /in/pdRdU on line 14 Notice: Use of undefined constant CURLOPT_RETURNTRANSFER - assumed 'CURLOPT_RETURNTRANSFER' in /in/pdRdU on line 15 Notice: Use of undefined constant CURLOPT_HEADER - assumed 'CURLOPT_HEADER' in /in/pdRdU on line 16 Notice: Use of undefined constant CURLOPT_FOLLOWLOCATION - assumed 'CURLOPT_FOLLOWLOCATION' in /in/pdRdU on line 17 Notice: Use of undefined constant CURLOPT_ENCODING - assumed 'CURLOPT_ENCODING' in /in/pdRdU on line 18 Notice: Use of undefined constant CURLOPT_AUTOREFERER - assumed 'CURLOPT_AUTOREFERER' in /in/pdRdU on line 19 Notice: Use of undefined constant CURLOPT_CONNECTTIMEOUT - assumed 'CURLOPT_CONNECTTIMEOUT' in /in/pdRdU on line 20 Notice: Use of undefined constant CURLOPT_TIMEOUT - assumed 'CURLOPT_TIMEOUT' in /in/pdRdU on line 21 Notice: Use of undefined constant CURLOPT_MAXREDIRS - assumed 'CURLOPT_MAXREDIRS' in /in/pdRdU on line 22 Fatal error: Uncaught Error: Call to undefined function curl_init() in /in/pdRdU:25 Stack trace: #0 /in/pdRdU(40): get_web_page('www.kompas.com') #1 {main} thrown in /in/pdRdU on line 25
Process exited with code 255.
Output for 5.5.0 - 5.5.38, 5.6.0 - 5.6.40
Notice: Use of undefined constant CURLOPT_CUSTOMREQUEST - assumed 'CURLOPT_CUSTOMREQUEST' in /in/pdRdU on line 10 Notice: Use of undefined constant CURLOPT_POST - assumed 'CURLOPT_POST' in /in/pdRdU on line 11 Notice: Use of undefined constant CURLOPT_USERAGENT - assumed 'CURLOPT_USERAGENT' in /in/pdRdU on line 12 Notice: Use of undefined constant CURLOPT_COOKIEFILE - assumed 'CURLOPT_COOKIEFILE' in /in/pdRdU on line 13 Notice: Use of undefined constant CURLOPT_COOKIEJAR - assumed 'CURLOPT_COOKIEJAR' in /in/pdRdU on line 14 Notice: Use of undefined constant CURLOPT_RETURNTRANSFER - assumed 'CURLOPT_RETURNTRANSFER' in /in/pdRdU on line 15 Notice: Use of undefined constant CURLOPT_HEADER - assumed 'CURLOPT_HEADER' in /in/pdRdU on line 16 Notice: Use of undefined constant CURLOPT_FOLLOWLOCATION - assumed 'CURLOPT_FOLLOWLOCATION' in /in/pdRdU on line 17 Notice: Use of undefined constant CURLOPT_ENCODING - assumed 'CURLOPT_ENCODING' in /in/pdRdU on line 18 Notice: Use of undefined constant CURLOPT_AUTOREFERER - assumed 'CURLOPT_AUTOREFERER' in /in/pdRdU on line 19 Notice: Use of undefined constant CURLOPT_CONNECTTIMEOUT - assumed 'CURLOPT_CONNECTTIMEOUT' in /in/pdRdU on line 20 Notice: Use of undefined constant CURLOPT_TIMEOUT - assumed 'CURLOPT_TIMEOUT' in /in/pdRdU on line 21 Notice: Use of undefined constant CURLOPT_MAXREDIRS - assumed 'CURLOPT_MAXREDIRS' in /in/pdRdU on line 22 Fatal error: Call to undefined function curl_init() in /in/pdRdU on line 25
Process exited with code 255.

preferences:
166.77 ms | 418 KiB | 5 Q