[英]html entities for utf-8 character in php
我在php中将html_entities用于UTF-8。
$input = "<div> 'Testing' </div>";
echo htmlentities($input,ENT_NOQUOTES,"UTF-8");
但是,上面的编码适用于普通输入,如果我给出下面的输入并使用编码,那么我将得到空白输出。
$input = "<div>Other 'user' is working on this line. Please contribute the next line.</div>";
echo htmlentities($input,ENT_NOQUOTES,"UTF-8");
我不知道这是如何给空白的输出。 如果我打印$ input,那么我将低于$ input的值。
<div>Other user working on this line.�Please contribute the next line.</div>
htmlentities代码中缺少任何内容,请提供您的建议。
谢谢,
-Pravin。
尝试先将$ input传递给utf8_encode,然后将数据传递给仅设置ENT_NOQUOTES选项的htmlentities:
<?php
$input = "<div>Other 'user' is working on this line. Please contribute the next line.</div>";
echo htmlentities(utf8_encode($input),ENT_NOQUOTES);
?>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.