我从数据库中获取了一个我想在文本框中显示的信息,但它总是失败。
我从数据库中得到的值:
$text = "Keith's Club";
echo "<input type='text' value='$text' />";
它应该Keith's Club
在文本框中返回,但发生的是它只显示Keith
我试过了
<input type='text' value='".htmlspecialchars(stripslashes($cname))."' />;
但它不起作用。
您应该确保使用 quotestyle 和 charset htmlentites()
,您的编辑器中的 php 页面应该被编码为:
$text = "Keith's Club";
echo "<input type'text' value='".htmlentities($text, ENT_QUOTES, 'UTF-8')."' />";
再次:确保您的编辑器中的 php 页面编码正确。
使用htmlentities:
echo '<input type="text" value="'. htmlentities($text) .'" />';
或者更好:
$text = htmlentities("Keith's Club");