[英]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.