LoginSignup
1
0

More than 5 years have passed since last update.

header Locationで「Warning: Cannot modify header information」がでた

Last updated at Posted at 2019-02-20

php.iniを設定して解決

何が起きたか?

どこのページを見ても
「Warning: Cannot modify header information」

。。。

グーグル先生に聞いたら一発で解決策を教えてくれた!

参考:http://kotori-blog.com/php/cmhi_error/
この方のページを見ながら、php.iniで設定を変更すれば細かいことは気にしないで
正常に動くとのことで、いざ実践。

設定ファイルが見つからない!

grep でどこに設定が置いてあるのか確認

$ php -i | grep php.ini
$ onfiguration File (php.ini) Path => /etc

。。。あれ? etcに「php.ini」がない・・・
ということで、作成します。

現状とりあえず動作を確認できれば良いので、

php.ini
; php.ini
default_charset = UTF-8
mbstring.internal_encoding = UTF-8
output_buffering = On  

上記で新しく「php.ini」を作成して、ビルドインサーバーを動かす際に、
読み込み先を指定しました。

php -S localhost:8000 -c php.ini

無事、「Warning: Cannot modify header information」が表示されなくなりました。

これから php の開発をメインに行っていくと思うので、
php についてもっと理解を深めていこうと思います。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0