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.'");">';
现在 - 这工作得很好 - 如果 $item->quote 和 $item->author 不包含任何值,例如:
我叔叔的房子 谁说“Ich bin ein Berliner”?
然后参数字符串会很混乱......
<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 '<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');">