未正确显示引号

Not rightly shown quotes

本文关键字:显示      更新时间:2023-09-26

我在 php 脚本中以 html 显示引号时遇到问题。此代码:

$str = '<select name=''image'' OnChange=''javascript:document.forms[0].showimage.src="' . $imgdir_ . '"+this.value+""''>';

结果:

<select name="image" onchange="javascript:document.forms[0].showimage.src=&quot;http://bitmirror.net/pic/categories/&quot;+this.value+&quot;&quot;">

请问有什么错?

谢谢

我假设你正在使用htmlspecialchars来输出你的字符串。您应该在 $flags 参数中使用标志ENT_NOQUOTES,以防止它将引号转换为 html 序列。

我认为你的问题通过转义字符串...

试试这个:

$str = "<select name='image' OnChange='javascript:document.forms[0].showimage.src=" . $imgdir . " +this.value>";