HTML字符在PHP中解析;反斜杠休息

时间:2015-10-02 04:36:00

标签: php html backslash

<script type="text/javascript">  
    Player.embed("ID", {soundFile: "http://yoursite.com/path/to/mp3_file.mp3"});  
    </script>

这是我需要在PHP中解析的代码片段。使用反斜杠中断需要哪些字符?

<script type=\"text\/javascript\">Player\.embed\(\"$2$3$4\"\, \{soundFile\: \"http://$2$3$4/$5\"\}\);  
    <\/script>

1 个答案:

答案 0 :(得分:0)

你的意思是:

 string addslashes ( string $str )

在需要转义的字符之前返回带反斜杠的字符串。这些字符是单引号(&#39;),双引号(&#34;),反斜杠(\)和NUL(NULL字节)。

此消息来源: http://php.net/manual/en/function.addslashes.php 还有这个: http://www.w3schools.com/php/func_string_addslashes.asp
从第二个源开始,添加转义字符可用于准备字符串以存储在数据库和数据库查询中。

-

注意:默认情况下,PHP会对所有GET,POST和COOKIE数据运行addslashes(),因此您不希望再次执行此操作并获得两倍的转义斜杠。

当你需要撤消它时,还有一个stripslashes()函数。 http://php.net/manual/en/function.stripslashes.php