您好我一直在使用这个php echo语句
echo "<a href = 'message_delete_script_outbox.php?id=".$row['id']."'"."onclick='return
confirm(/Are you sure, you want to delete?/)'>Delete</a>";
该声明正在工作我看到此消息/您确定要删除吗?/而不是此您确定要删除吗?
答案 0 :(得分:5)
你的报价嵌套有点搞砸了。请尝试遵循以下规则:
"
(这标志着字符串的开头和结尾)\"
(转义为不标记“字符串的开头/结尾”)'
(字面引用)\'
(将作为转义外部报价生成的字面引用)结果:
echo "<a href=\"message_delete_script_outbox.php?id=".$row['id']."\"onclick=
\"return confirm('Are you sure, you want to delete?')\">Delete</a>";
有关报价嵌套的更多信息:http://blog.opensourceopportunities.com/2007/10/nested-nested-quotes.html
答案 1 :(得分:1)
您将邮件括在引号中,并且需要对这些引号进行转义以避免混淆PHP脚本:
echo "<a href = 'message_delete_script_outbox.php?id=".$row['id']."'"."onclick='return
confirm(\"Are you sure, you want to delete?\")'>Delete</a>";
答案 2 :(得分:1)
只需添加双引号并将其转义
echo "<a href = 'message_delete_script_outbox.php?id=".$row['id']."' onclick='return confirm(\"Are you sure, you want to delete?\")'>Delete</a>";
我不确定您在此处发布时是否添加了新行,但您应该知道您不能在2行上添加该脚本。