3v4l.org

run code in 300+ PHP versions simultaneously
<?php function doHttpRequest($url, $post_data = NULL, $method = 'GET',) { $ch = curl_init(); $options = array( CURLOPT_URL => $url, CURLOPT_RETURNTRANSFER => TRUE, CURLOPT_HEADER => FALSE, CURLOPT_CUSTOMREQUEST => $method ); if (isset($post_data)){ if($method == "POST") { $options[CURLOPT_POST] = TRUE; $options[CURLOPT_POSTFIELDS] = $post_data; } else { $options[CURLOPT_URL] = $url .'?'. http_build_query($post_data,'','&'); } } curl_setopt_array($ch, $options); $response = curl_exec($ch); curl_close($ch); return $response; } $post_data = array( 'apiKey' => 'bbd9f56b9ec239745931df1026baee74', 'campaign' => '4732' ); $data = doHttpRequest('http://theappreciationengine.com/api/top',$post_data); ?>
Output for 8.1.23 - 8.1.28, 8.2.10 - 8.2.19, 8.3.0 - 8.3.7
Fatal error: Uncaught Error: Call to undefined function curl_init() in /in/SHl7L:3 Stack trace: #0 /in/SHl7L(27): doHttpRequest('http://theappre...', Array) #1 {main} thrown in /in/SHl7L on line 3
Process exited with code 255.
Output for 5.4.0 - 5.4.26
Parse error: syntax error, unexpected ')', expecting '&' or variable (T_VARIABLE) in /in/SHl7L on line 2
Process exited with code 255.
Output for 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.28
Parse error: syntax error, unexpected ')', expecting '&' or T_VARIABLE in /in/SHl7L on line 2
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Parse error: parse error, unexpected ')', expecting '&' or T_VARIABLE in /in/SHl7L on line 2
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected ')', expecting '&' or T_VARIABLE or T_CONST in /in/SHl7L on line 2
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1
Parse error: parse error, unexpected ')', expecting '&' or T_VARIABLE or T_CONST in /in/SHl7L on line 2
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `'&'' or `T_VARIABLE' or `T_CONST' in /in/SHl7L on line 2
Process exited with code 255.

preferences:
119.65 ms | 401 KiB | 138 Q