是否有PHP版本的confirm()函数?
如果没有,我的其他选择是什么,或者我如何制作类似于confirm()的内容?
因为PHP是服务器端语言(所有PHP代码都在服务器上执行,代码的输出发送到客户端),所以你必须使用提交或取消按钮制作一个HTML表单.你的PHP页面.像这样的东西:
confirm.php:
<p>Are you sure you want to do this?</p>
<form action="page2.php" method="post">
<input type="submit" name="ok" value="OK" />
<input type="submit" name="cancel" value="Cancel" />
</form>
Run Code Online (Sandbox Code Playgroud)
使page2.php:
<?php
if (isset($_POST['ok'])) {
// They pressed OK
}
if (isset($_POST['cancel'])) {
// They pressed Cancel
}
?>
Run Code Online (Sandbox Code Playgroud)