LoginSignup
4
4

More than 5 years have passed since last update.

phpで特殊文字をエンコード&デコード

Last updated at Posted at 2014-04-16

まとめて対象にしたいときは
htmlentities/html_entity_decode

特定の特殊文字だけを対象にしたいときは
htmlspecialchars/htmlspecialchars_decode

上記2つの関数の違いは、htmlentities がエンコード可能なものはすべてエンコードするが、 htmlspecialchars は、不等号(<>)、アンパサンド(&)、シングルコーテーション(')、ダブルコーテーション(") のみをエンコードすることである。 htmlentities では コピーライト文字もエンコードされているが、htmlspecialchars ではコピーライト(©)の変換は 行われていないことがわかる。

smartyテンプレートで画面に出力している場合は、更に
smarty:nodefaults
を噛ませる必要があることに注意。

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