好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

phphtml_entity_decode函数怎么用

html_entity_decode()函数用于把 HTML 实体转换为字符,语法为html_entity_decode(string,flags,character-set)。

● Shift_JIS - 日语

● EUC-JP - 日语

● MacRoman - Mac 操作系统使用的字符集

注释:在 PHP 5.4 之前的版本,无法被识别的字符集将被忽略并由 ISO-8859-1 替代。自 PHP 5.4 起,无法被识别的字符集将被忽略并由 UTF-8 替代。

返回值: 返回被转换的字符串

下面通过示例来看看php strstr()函数的使用方法。

示例1: 把 HTML 实体转换为字符

<?php
$str = "Bill &amp; &#039;Steve&#039;";
echo html_entity_decode($str, ENT_COMPAT); // 只转换双引号
echo "<br>";
echo html_entity_decode($str, ENT_QUOTES); // 转换双引号和单引号
echo "<br>";
echo html_entity_decode($str, ENT_NOQUOTES); // 不转换任何引号
?>

输出:

示例2: 通过使用西欧字符集,把 HTML 实体转换为字符

<?php
$str = "My name is ?yvind ?sane. I'm Norwegian.";
echo html_entity_decode($str, ENT_QUOTES, "ISO-8859-1");
?>

以上代码的 HTML 输出(查看源代码):

<!DOCTYPE html>
<html>
<body>
My name is ?yvind ?sane. I'm Norwegian.
</body>
</html>

以上代码的浏览器输出:

My name is ?yvind ?sane. I'm Norwegian.

以上就是php html_entity_decode函数怎么用的详细内容,更多请关注Gxl网其它相关文章!

查看更多关于phphtml_entity_decode函数怎么用的详细内容...

  阅读:46次