嗨我一直在使用这个 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>";
该声明正在运行我看到此消息/您确定,您要删除吗?/而不是此您确定,您要删除吗?
嗨我一直在使用这个 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>";
该声明正在运行我看到此消息/您确定,您要删除吗?/而不是此您确定,您要删除吗?
您的报价嵌套有点混乱。尝试遵循以下规则:
"
(这标志着字符串的开始和结束)\"
(转义为不标记“字符串开头/结尾”)'
(字面报价)\'
(将作为转义的外部引用生成的文字引用)结果:
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
您将消息括在引号中,这些引号需要转义以避免混淆 PHP 脚本:
echo "<a href = 'message_delete_script_outbox.php?id=".$row['id']."'"."onclick='return
confirm(\"Are you sure, you want to delete?\")'>Delete</a>";
只需添加双引号并转义它们
echo "<a href = 'message_delete_script_outbox.php?id=".$row['id']."' onclick='return confirm(\"Are you sure, you want to delete?\")'>Delete</a>";
我不确定您在此处发布时是否添加了新行,但您应该知道您不能将该脚本放在 2 行上。