1

投稿後にユーザーが入力したデータの.etc&quot;を保持しながら、特殊文字 ( ) または何を変換する htmlentities や htmlspecialchars のような関数はありますか?<br><span>

4

2 に答える 2

0

を検索していただければ幸いですhtmlspecialchars_decode()

例を以下に示します。

<?php
$str = "<p>this -&gt; &quot;</p>\n";

echo htmlspecialchars_decode($str);

// note that here the quotes aren't converted
echo htmlspecialchars_decode($str, ENT_NOQUOTES);
?>

Php.netリンク

于 2013-03-01T05:24:27.037 に答える
0

必要なものを取得するには、次の 2 つの方法があります。

<?php

      $str = "<p>this -&gt; &quot;</p>\n";

       //Encoding
       $encoded = htmlentities($str);

      //Decoding note that here the quotes aren't converted
     echo htmlspecialchars_decode($encoded, ENT_NOQUOTES);
 ?>

エントリをそのまま DB に保存する場合は、addslashes を使用してそのまま保存します

于 2013-03-01T05:30:05.377 に答える