【发布时间】:2016-03-02 15:22:30
【问题描述】:
您好需要帮助才能在 html 中运行以下 php。
function runMyFunction(){
$_SESSION["identificate"] = 'no';
session_destroy();
header('Location: Login.html');
}
---------------------------------------------------------
<div id="foo">
<button type="button" onclick="runMyFunction()">Logout
</button>
</div>
谢谢
【问题讨论】:
-
PHP 是一种服务器端语言。这意味着它在访问者在浏览器中看到输出之前执行。最好的解决方案是使用 Javascript 向 php 文件创建重定向,并使用
header('location: .. ')将它们再次发送回去或使用 Ajax。