在字符串中使用htmlentities
问题描述:
我知道我应该在所有表单文本输入字段中使用htmlentities,但这不起作用:
I know I should be using htmlentities for all my form text input fields but this doesn't work:
<?php
echo "<tr>
<td align=\"right\">".Telephone." :</td>
<td><input type=\"text\" name=\"telephone\" size=\"27\"
value=\"htmlentities($row[telephone])\"> Inc. dialing codes
</td>
</tr>";
?>
它只是以形式将输入值显示为"htmlentities(0123456789)"?我做错了什么吗?
It simply shows the input value as "htmlentities(0123456789)" in the form? What have I done wrong please?
答
尝试使用
value=\"" . htmlentities($row[telephone]) . "\"
有.当前,您的字符串仅包含htmlentities字符串,并将变量拼接到其中.您需要取出字符串,调用函数并将其结果放在适当的位置,如上所述.
there. Currently, your string simply contains the htmlentities string and splices the variable in. You need to get out the string, call the function and put it's result in place, as above.