Home > Backend Development > PHP Tutorial > htmlentities() 单双引号不转换解决办法

htmlentities() 单双引号不转换解决办法

WBOY
Release: 2016-06-13 10:10:15
Original
795 people have browsed it

htmlentities() 单双引号不转换

PHP code
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--><?php $str = "John & 'Adams'";echo htmlentities($str, ENT_COMPAT);echo "<br />";echo htmlentities($str, ENT_QUOTES);echo "<br>";echo htmlentities($str, ENT_NOQUOTES);?>
Copy after login


如下是我截图,为什么对单双引号不转换??

如下是我浏览器输出

HTML code
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->John & 'Adams'<br>John & 'Adams'<br>John & 'Adams'
Copy after login




------解决方案--------------------
那么那些&打头的是什么?
------解决方案--------------------
?ENT_COMPAT - 默认。仅编码双引号。
?ENT_QUOTES - 编码双引号和单引号。
?ENT_NOQUOTES - 不编码任何引号。
------解决方案--------------------
' 就是单引号
------解决方案--------------------
估计楼主看的是HTML在浏览器中显示出来的效果,而不是看的HTML源码
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template