[PHP]htmlspecialchars, htmlentitiesのオプション

Tags: ,

メモ。

シングル・ダブルクオーテーションに関する動作を示すオプションの第2の引数をとり、無指定でデフォルトはENT_COMPAT(ダブルクオーテーションを変換、シングルクオーテーションを無変換)。ENT_QUOTESでダブルおよびシングルクオーテーションをそれぞれ”、’に変換。


<?php
$text = htmlspecialchars($_POST['text'], ENT_QUOTES);
?>

[Reference]
htmlentities - PHPマニュアル
htmlspecialchars - PHPマニュアル

Related posts:



Trackback URL

Comments

Leave a Reply