PHP|Warning: Cannot modify header information – headers already sent
『Warning: Cannot modify header information – headers already sent』が出力される原因についてメモ
スポンサーリンク
『Warning: Cannot modify header information – headers already sent』の出力原因
『Warning: Cannot modify header information – headers already sent』は、HTTPヘッダーを出力する前に何かしらの出力がある場合に出力されます。
HTTPヘッダーを送る際に関係無い文字列が送られると誤動作の原因となるためです。
例えば、以下のケースで出力されます。
echo "test"; header("Location: https://www.google.co.jp"); exit;
更新日:2018年10月05日
作成日:2018年10月05日