字符串处理Java/html/php echo';
现在-如果$item->quote和$item->author不包含以下值,则此操作非常有效: 我叔叔的房子 谁说“我是柏林人” 那么params字符串将非常混乱字符串处理Java/html/php echo';,php,javascript,html,Php,Javascript,Html,现在-如果$item->quote和$item->author不包含以下值,则此操作非常有效: 我叔叔的房子 谁说“我是柏林人” 那么params字符串将非常混乱 echo '<button class="modalInput" title="Is there an error in this question, report it here." rel="#prompt" onClick="params('.$item->catid.','.$item->id.',"'.$i
echo '<button class="modalInput" title="Is there an error in this question, report it here." rel="#prompt" onClick="params('.$item->catid.','.$item->id.',"'.$item->quote.'","'.$item->author.'");">';
我怎样才能解决这个问题
还是不行
<button class="modalInput" title="Is there an error in this question, report it here." rel="#prompt" onClick="params(21,12,"Who said "ich bin ein Berliner"","George Bush");">
echo';
变成
echo '<button class="modalInput" title="Is there an error in this question, report it here." rel="#prompt" onClick="params('.$item->catid.','.$item->id.',\''.htmlspecialchars($item->quote).'\',\''.(string) htmlspecialchars($item->author).'\');">';
使用函数,它将编码(转义)特殊字符,例如“
将变成”
:
没问题:)我还没有编辑完我的代码,所以我已经重写了它
<button class="modalInput" title="Is there an error in this question, report it here." rel="#prompt" onClick="params(29,29,'In a FOX TV show, what did 'The OC' stand for','Orange County');">
echo htmlspecialchars($item->quote);