0
0

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 3 years have passed since last update.

json_encode()で日本語が文字化け Unicodeエスケープさせない

Posted at

用途

json_encode()で日本語の表示が文字化けしないようにしたい時に使う。

使用方法

$hoge = [ "hoge" => "ほげほげほげほげ" ];
json_encode($hoge, JSON_UNESCAPED_UNICODE);    

// 結果 {"hoge":"ほげほげほげほげ"}

解説

JSON_UNESCAPED_UNICODE オプションを json_encode() の第2引数に指定することで、日本語の文字化けを防げる。(Unicodeエスケープさせないようにする)

0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?