这个函数,将会把' & 等直接转换为’ (单引号) 和 &
比如 you appreciate the driver's consideration , & 就会变成 you appreciate the driver’s consideration , &
PHP 默认有函数将 HTML字符编码 转换到 特殊字符
html_entity_decode (PHP 4 >= 4.3.0, PHP 5)
string html_entity_decode ( string $string
[, int $flags
= ENT_COMPAT | ENT_HTML401 [, string $encoding
= 'UTF-8' ]] )
html_entity_decode — Convert all HTML entities to their applicable characters (转换所有的HTML字符编码到对应的特殊字符串)
注意这个函数的参数ENT_COMPAT 默认会转换双引号,不会转换单引号;
为了能够同时转换单引号和双引号,需要使用 int $flags = ENT_QUOTES
通过以下的这段PHP处理数据库中的值:
html_entity_decode($node->body, ENT_QUOTES | ENT_HTML401)
这个函数,将会把' & 等直接转换为’ (单引号) 和 &
比如 you appreciate the driver's consideration , & 就会变成 you appreciate the driver’s consideration , &
假设在HTML文本框中输入这三行内容:
you appreciate the driver's consideration , &
you appreciate the driver's consideration , &
you appreciate the driver’s consideration , &
如下图:
点击“确定”按钮后,执行JQuery Ajax Post 操作 通过PHP插入到数据库;
(...)
Read the rest of HTML字符编码JS和PHP 转义 (108 words)
© lixiphp for LixiPHP, 2013. |
Permalink |
No comment |
Add to
del.icio.us
Post tags: html, JQuery, js, MySQL, PHP, 字符编码, 转义
Feed enhanced by Better Feed from Ozh
声明:本网页内容旨在传播知识,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。TEL:177 7030 7066 E-MAIL:11247931@qq.com