3v4l.org

run code in 300+ PHP versions simultaneously
<?php // 投稿先とAPIトークンを指定 $room_id = yyyyyy; // ルームID。URLからも確認できます $api_token = "******************"; // APIトークン // メッセージ本文 $body = <<<EOD テストメッセージでござる。 このメッセージはChatwork APIにより自動で投稿されてるでござるよ。 EOD; // ヘッダ header("Content-type: text/html; charset=utf-8"); // POST送信データ $params = array( 'body' => $body ); // cURLに渡すオプションを設定 $options = array( CURLOPT_URL => "https://api.chatwork.com/v1/rooms/{$room_id}/messages", // URL CURLOPT_HTTPHEADER => array('X-ChatWorkToken: '. $api_token), // APIトークン CURLOPT_RETURNTRANSFER => true, // 結果を文字列で返す CURLOPT_SSL_VERIFYPEER => false, // サーバー証明書の検証を行わない CURLOPT_POST => true, // HTTP POSTを実行 CURLOPT_POSTFIELDS => http_build_query($params, '', '&'), // POST送信データ ); // cURLセッションを初期化 $ch = 1; // cURL転送用の複数のオプションを設定 curl_setopt_array($ch, $options); // cURLセッションを実行 $response = curl_exec($ch); // cURLセッションをクローズ curl_close($ch); // 結果のJSON文字列をデコード $result = json_decode($response); // 結果を出力 (メッセージID返ってきてる) var_dump($result); ?>
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 "yyyyyy" in /in/Re3LH:4 Stack trace: #0 {main} thrown in /in/Re3LH on line 4
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 "yyyyyy" in /in/Re3LH:4 Stack trace: #0 {main} thrown in /in/Re3LH on line 4
Process exited with code 255.
Output for 7.2.0 - 7.2.33, 7.3.16 - 7.3.33, 7.4.0 - 7.4.33
Warning: Use of undefined constant yyyyyy - assumed 'yyyyyy' (this will throw an Error in a future version of PHP) in /in/Re3LH on line 4 Warning: Cannot modify header information - headers already sent by (output started at /in/Re3LH:4) in /in/Re3LH on line 16 Warning: Use of undefined constant CURLOPT_URL - assumed 'CURLOPT_URL' (this will throw an Error in a future version of PHP) in /in/Re3LH on line 25 Warning: Use of undefined constant CURLOPT_HTTPHEADER - assumed 'CURLOPT_HTTPHEADER' (this will throw an Error in a future version of PHP) in /in/Re3LH on line 26 Warning: Use of undefined constant CURLOPT_RETURNTRANSFER - assumed 'CURLOPT_RETURNTRANSFER' (this will throw an Error in a future version of PHP) in /in/Re3LH on line 27 Warning: Use of undefined constant CURLOPT_SSL_VERIFYPEER - assumed 'CURLOPT_SSL_VERIFYPEER' (this will throw an Error in a future version of PHP) in /in/Re3LH on line 28 Warning: Use of undefined constant CURLOPT_POST - assumed 'CURLOPT_POST' (this will throw an Error in a future version of PHP) in /in/Re3LH on line 29 Warning: Use of undefined constant CURLOPT_POSTFIELDS - assumed 'CURLOPT_POSTFIELDS' (this will throw an Error in a future version of PHP) in /in/Re3LH on line 30 Fatal error: Uncaught Error: Call to undefined function curl_setopt_array() in /in/Re3LH:37 Stack trace: #0 {main} thrown in /in/Re3LH on line 37
Process exited with code 255.
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.20
Notice: Use of undefined constant yyyyyy - assumed 'yyyyyy' in /in/Re3LH on line 4 Warning: Cannot modify header information - headers already sent by (output started at /in/Re3LH:4) in /in/Re3LH on line 16 Notice: Use of undefined constant CURLOPT_URL - assumed 'CURLOPT_URL' in /in/Re3LH on line 25 Notice: Use of undefined constant CURLOPT_HTTPHEADER - assumed 'CURLOPT_HTTPHEADER' in /in/Re3LH on line 26 Notice: Use of undefined constant CURLOPT_RETURNTRANSFER - assumed 'CURLOPT_RETURNTRANSFER' in /in/Re3LH on line 27 Notice: Use of undefined constant CURLOPT_SSL_VERIFYPEER - assumed 'CURLOPT_SSL_VERIFYPEER' in /in/Re3LH on line 28 Notice: Use of undefined constant CURLOPT_POST - assumed 'CURLOPT_POST' in /in/Re3LH on line 29 Notice: Use of undefined constant CURLOPT_POSTFIELDS - assumed 'CURLOPT_POSTFIELDS' in /in/Re3LH on line 30 Fatal error: Uncaught Error: Call to undefined function curl_setopt_array() in /in/Re3LH:37 Stack trace: #0 {main} thrown in /in/Re3LH on line 37
Process exited with code 255.

preferences:
152.44 ms | 403 KiB | 173 Q