2
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

PHPで出力した表示が文字化けしたとき

Posted at

PHPで出力した文字が化けるときの対策

php.ini内にて、default_charsetをUTF-8に指定してあげれば良い。
何も変更していない状態だとコメントアウトされているはずなので、こいつを生かしてやればOK.

; PHP's default character set is set to empty.
; http://php.net/default-charset
default_charset = "UTF-8"

ファイルの場所はUbuntu14.04の場合、
/etc/php5/apache2/php.ini
にあるかと。

別の策

PHPにてheader関数を利用してUTF-8を別途指定する。
スクリプトごとに指定するのは面倒ではあるが、知識としてメモしておく。

<?php
header("Content-Type: text/html; charset=UTF-8");
?>
2
3
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
2
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?