3v4l.org

run code in 300+ PHP versions simultaneously
<?php set_time_limit(0); ini_set('memory_limit', '2256M'); CHAT_KEY = 'key' try { $payload = "GET ALL DATA"; $ch = curl_init("https://url"); curl_setopt_array($ch, [ CURLOPT_RETURNTRANSFER => true, CURLOPT_POST => true, CURLOPT_HTTPHEADER => [ "Content-Type: application/json", "Authorization: Bearer " . CHAT_KEY ], CURLOPT_POSTFIELDS => json_encode($payload, JSON_UNESCAPED_UNICODE), CURLOPT_TIMEOUT => 1000, CURLOPT_FAILONERROR => true ]); $response = curl_exec($ch); curl_close($ch); $decoded = json_decode($response, true); $content = $decoded['choices'][0]['message']['content']; echo $content; } catch (Throwable $e) { // This guarantees something shows up instead of silent 500 error_log($e->getMessage()); echo $e->getMessage(); }<?php set_time_limit(0); ini_set('memory_limit', '2256M'); CHAT_KEY = 'key' try { $payload = "GET ALL DATA"; $ch = curl_init("https://url"); curl_setopt_array($ch, [ CURLOPT_RETURNTRANSFER => true, CURLOPT_POST => true, CURLOPT_HTTPHEADER => [ "Content-Type: application/json", "Authorization: Bearer " . CHAT_KEY ], CURLOPT_POSTFIELDS => json_encode($payload, JSON_UNESCAPED_UNICODE), CURLOPT_TIMEOUT => 1000, CURLOPT_FAILONERROR => true ]); $response = curl_exec($ch); curl_close($ch); $decoded = json_decode($response, true); $content = $decoded['choices'][0]['message']['content']; echo $content; } catch (Throwable $e) { // This guarantees something shows up instead of silent 500 error_log($e->getMessage()); echo $e->getMessage(); }
Output for 8.3.0 - 8.3.29, 8.4.1 - 8.4.16, 8.5.0 - 8.5.1
Parse error: syntax error, unexpected token "=" in /in/NqTab on line 4
Process exited with code 255.

preferences:
151.26 ms | 1008 KiB | 7 Q