PHP不应该在javascript中运行 [英] PHP runs when not supposed to in javascript
本文介绍了PHP不应该在javascript中运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在php中有以下代码:
echo ' < head>< script type =text / javascript> function EndSession(){
var _endSession = confirm(结束当前编辑会话?);
if(_endSession == true)
{';
未设置($ _ SESSION [' UsernameC']);
echo ' alert(会话终止。 );
window.location =index.php?page = acp;
}
其他
{
alert(会话有效。);
}
}< / script>< / head>';
你可以注意到''unset($ _ SESSION [''UsernameC'']); ''是php脚本的一部分,只能在javascript中运行,但它可以随时运行,有没有办法解决它?
解决方案
_SESSION [ ' UsernameC']);
echo ' alert(会话终止。 );
window.location =index.php?page = acp;
}
其他
{
alert(会话有效。);
}
}< / script>< / head>';
你可以注意到''unset(
_SESSION [''UsernameC'']); ''是php脚本的一部分,只能在javascript中运行,但它可以随时运行,有没有办法解决它?
未设置(
I have the following code in php:
echo '<head><script type="text/javascript">function EndSession() {
var _endSession = confirm("End current editing session ?");
if(_endSession == true)
{';
unset($_SESSION['UsernameC']);
echo 'alert("Session terminated.");
window.location = "index.php?page=acp";
}
else
{
alert("Session active.");
}
}</script></head>';
You can notice the '' unset($_SESSION[''UsernameC'']); '' is part of the php script, that ment to run only inside the javascript, but it runs anytime, is there any way to fix it ?
解决方案
_SESSION['UsernameC']); echo 'alert("Session terminated."); window.location = "index.php?page=acp"; } else { alert("Session active."); } }</script></head>';
You can notice the '' unset(
_SESSION[''UsernameC'']); '' is part of the php script, that ment to run only inside the javascript, but it runs anytime, is there any way to fix it ?
unset(
这篇关于PHP不应该在javascript中运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文