3v4l.org

run code in 300+ PHP versions simultaneously
<?php function hhb_curl_init($custom_options_array = array()) { if(empty($custom_options_array)){ $custom_options_array=array(); //i feel kinda bad about this.. argv[1] of curl_init wants a string(url), or NULL //at least i want to allow NULL aswell :/ } if (!is_array($custom_options_array)) { throw new InvalidArgumentException('$custom_options_array must be an array!'); }; $options_array = array( CURLOPT_AUTOREFERER => true, CURLOPT_BINARYTRANSFER => true, CURLOPT_COOKIESESSION => true, CURLOPT_FOLLOWLOCATION => true, CURLOPT_FORBID_REUSE => false, CURLOPT_HTTPGET => true, CURLOPT_RETURNTRANSFER => true, CURLOPT_SSL_VERIFYPEER => false, CURLOPT_CONNECTTIMEOUT => 10, CURLOPT_TIMEOUT => 11, //CURLOPT_REFERER=>'hanshenrik.tk', ); if (!array_key_exists(CURLOPT_COOKIEFILE, $custom_options_array)) { //do this only conditionally because tmpfile() call.. //we want PHP5.3- support -.- //for 5.4, just: $options_array[CURLOPT_COOKIEFILE]=stream_get_meta_data(tmpfile())['uri']; //static arr workaround for https://bugs.php.net/bug.php?id=66014 ... static $curl_cookiefile_filehandle_arr=array(); $curl_filehandle_arr[]=$options_array[CURLOPT_COOKIEFILE] = tmpfile(); $options_array[CURLOPT_COOKIEFILE] =stream_get_meta_data($options_array[CURLOPT_COOKIEFILE]); $options_array[CURLOPT_COOKIEFILE]=$options_array[CURLOPT_COOKIEFILE]['uri']; } //we can't use array_merge() because of how it handles integer-keys, it would/could cause corruption foreach($custom_options_array as $key => $val) { $options_array[$key] = $val; } unset($key, $val, $custom_options_array); $curl = curl_init(); curl_setopt_array($curl, $options_array); return $curl; } for($i=0;$i<9;++$i){ var_dump(hhb_curl_init()); }
Output for git.master, git.master_jit, rfc.property-hooks
Fatal error: Uncaught Error: Undefined constant "CURLOPT_AUTOREFERER" in /in/YE23c:12 Stack trace: #0 /in/YE23c(45): hhb_curl_init() #1 {main} thrown in /in/YE23c on line 12
Process exited with code 255.

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
45.28 ms | 401 KiB | 8 Q