3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * Send a POST requst using cURL * @param string $url to request * @param array $post values to send * @param array $options for cURL * @return string */ function curl_post($url, array $post = NULL) { $defaults = array( CURLOPT_POST => 1, CURLOPT_HEADER => 0, CURLOPT_URL => $url, CURLOPT_FRESH_CONNECT => 1, CURLOPT_RETURNTRANSFER => 1, CURLOPT_FORBID_REUSE => 1, CURLOPT_TIMEOUT => 4, CURLOPT_POSTFIELDS => http_build_query($post) ); $ch = curl_init(); curl_setopt_array($ch, ($defaults)); if( ! $result = curl_exec($ch)) { trigger_error(curl_error($ch)); } curl_close($ch); return $result; } $ul = "http://localhost:8080/admin-app/service/sites/1/providers"; $reopt = array(); $postdata = array('key' => 'jHsYiWWRZDq5Sq3N'); $resp = curl_post($ul, $postdata, $reopt); ?>
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
Fatal error: Uncaught Error: Undefined constant "CURLOPT_POST" in /in/6IWfF:12 Stack trace: #0 /in/6IWfF(35): curl_post('http://localhos...', Array, Array) #1 {main} thrown in /in/6IWfF on line 12
Process exited with code 255.
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 Fatal error: Uncaught Error: Undefined constant "CURLOPT_POST" in /in/6IWfF:12 Stack trace: #0 /in/6IWfF(35): curl_post('http://localhos...', Array, Array) #1 {main} thrown in /in/6IWfF on line 12
Process exited with code 255.
Output for 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
Warning: Use of undefined constant CURLOPT_POST - assumed 'CURLOPT_POST' (this will throw an Error in a future version of PHP) in /in/6IWfF on line 12 Warning: Use of undefined constant CURLOPT_HEADER - assumed 'CURLOPT_HEADER' (this will throw an Error in a future version of PHP) in /in/6IWfF on line 13 Warning: Use of undefined constant CURLOPT_URL - assumed 'CURLOPT_URL' (this will throw an Error in a future version of PHP) in /in/6IWfF on line 14 Warning: Use of undefined constant CURLOPT_FRESH_CONNECT - assumed 'CURLOPT_FRESH_CONNECT' (this will throw an Error in a future version of PHP) in /in/6IWfF on line 15 Warning: Use of undefined constant CURLOPT_RETURNTRANSFER - assumed 'CURLOPT_RETURNTRANSFER' (this will throw an Error in a future version of PHP) in /in/6IWfF on line 16 Warning: Use of undefined constant CURLOPT_FORBID_REUSE - assumed 'CURLOPT_FORBID_REUSE' (this will throw an Error in a future version of PHP) in /in/6IWfF on line 17 Warning: Use of undefined constant CURLOPT_TIMEOUT - assumed 'CURLOPT_TIMEOUT' (this will throw an Error in a future version of PHP) in /in/6IWfF on line 18 Warning: Use of undefined constant CURLOPT_POSTFIELDS - assumed 'CURLOPT_POSTFIELDS' (this will throw an Error in a future version of PHP) in /in/6IWfF on line 19 Fatal error: Uncaught Error: Call to undefined function curl_init() in /in/6IWfF:22 Stack trace: #0 /in/6IWfF(35): curl_post('http://localhos...', Array, Array) #1 {main} thrown in /in/6IWfF on line 22
Process exited with code 255.
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.33
Notice: Use of undefined constant CURLOPT_POST - assumed 'CURLOPT_POST' in /in/6IWfF on line 12 Notice: Use of undefined constant CURLOPT_HEADER - assumed 'CURLOPT_HEADER' in /in/6IWfF on line 13 Notice: Use of undefined constant CURLOPT_URL - assumed 'CURLOPT_URL' in /in/6IWfF on line 14 Notice: Use of undefined constant CURLOPT_FRESH_CONNECT - assumed 'CURLOPT_FRESH_CONNECT' in /in/6IWfF on line 15 Notice: Use of undefined constant CURLOPT_RETURNTRANSFER - assumed 'CURLOPT_RETURNTRANSFER' in /in/6IWfF on line 16 Notice: Use of undefined constant CURLOPT_FORBID_REUSE - assumed 'CURLOPT_FORBID_REUSE' in /in/6IWfF on line 17 Notice: Use of undefined constant CURLOPT_TIMEOUT - assumed 'CURLOPT_TIMEOUT' in /in/6IWfF on line 18 Notice: Use of undefined constant CURLOPT_POSTFIELDS - assumed 'CURLOPT_POSTFIELDS' in /in/6IWfF on line 19 Fatal error: Uncaught Error: Call to undefined function curl_init() in /in/6IWfF:22 Stack trace: #0 /in/6IWfF(35): curl_post('http://localhos...', Array, Array) #1 {main} thrown in /in/6IWfF on line 22
Process exited with code 255.
Output for 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_POST - assumed 'CURLOPT_POST' in /in/6IWfF on line 12 Notice: Use of undefined constant CURLOPT_HEADER - assumed 'CURLOPT_HEADER' in /in/6IWfF on line 13 Notice: Use of undefined constant CURLOPT_URL - assumed 'CURLOPT_URL' in /in/6IWfF on line 14 Notice: Use of undefined constant CURLOPT_FRESH_CONNECT - assumed 'CURLOPT_FRESH_CONNECT' in /in/6IWfF on line 15 Notice: Use of undefined constant CURLOPT_RETURNTRANSFER - assumed 'CURLOPT_RETURNTRANSFER' in /in/6IWfF on line 16 Notice: Use of undefined constant CURLOPT_FORBID_REUSE - assumed 'CURLOPT_FORBID_REUSE' in /in/6IWfF on line 17 Notice: Use of undefined constant CURLOPT_TIMEOUT - assumed 'CURLOPT_TIMEOUT' in /in/6IWfF on line 18 Notice: Use of undefined constant CURLOPT_POSTFIELDS - assumed 'CURLOPT_POSTFIELDS' in /in/6IWfF on line 19 Fatal error: Call to undefined function curl_init() in /in/6IWfF on line 22
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Parse error: parse error, unexpected T_ARRAY, expecting '&' or T_VARIABLE in /in/6IWfF on line 9
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_ARRAY, expecting '&' or T_VARIABLE or T_CONST in /in/6IWfF on line 9
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 T_ARRAY, expecting '&' or T_VARIABLE or T_CONST in /in/6IWfF on line 9
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/6IWfF on line 9
Process exited with code 255.

preferences:
218.32 ms | 401 KiB | 357 Q