php标签不适用于我的javascript [英] php tags dont work in javascript for me
问题描述
我正在尝试使用$ _SESSION为管理员创建一个控制面板。
现在我创建了一个javascript控制按钮,要求终止当前会话,这将使其成为删除$ _SESSION((取消设置))。
我使用过这个javascript代码:
I''m trying to make a Control Panel for admins with a $_SESSION.
Now I have created a javascript controlled button that asks to terminate the current session, and that will make it to delete the $_SESSION ((unset it)).
I have used this javascript code:
<script type="text/javascript">function Test() {
var _endSession = confirm("End current editing session ?");
if(_endSession == true)
{
<?php
unset($_SESSION['."'UsernameChosen'".');
?>
alert("Session terminated.");
}
else
{
alert("Session active.");
}
}</script>
如果删除标签,它只适用于警报。
但如果我删除未设置它仍然无法正常工作。所以我只是假设javascript中的php标签运行不正常,我做错了什么或者php是不是可以在javascript中使用?如果我不能怎么做这个函数脚本?
If I remove the tag, it''ll work with only the alerts.
But if I remove the unset it still wouldn''t work. So I just assumed that the php tags in javascript aren''t functioning right, did I do anything wrong or is php isn''t workable in javascript ? If it isn''t how could I do this function script ?
推荐答案
_SESSION。
现在我已经创建了一个javascript控制按钮要求终止当前会话,这将使其删除
_SESSION.
Now I have created a javascript controlled button that asks to terminate the current session, and that will make it to delete the
_SESSION((取消设置))。
我使用了这个javascript代码:
_SESSION ((unset it)).
I have used this javascript code:
<script type="text/javascript">function Test() {
var _endSession = confirm("End current editing session ?");
if(_endSession == true)
{
<?php
unset(
_SESSION [' 。' UsernameChosen ' 。);
?>
alert( 会话终止。);
}
其他
{
alert( 会话处于活动状态。);
}
}< / script>
_SESSION['."'UsernameChosen'".'); ?> alert("Session terminated."); } else { alert("Session active."); } }</script>
如果删除标签,它只适用于警报。
但如果我删除未设置它仍然无法正常工作。所以我只是假设javascript中的php标签运行不正常,我做错了什么或者php是不是可以在javascript中使用?如果我不能怎么做这个功能脚本?
If I remove the tag, it''ll work with only the alerts.
But if I remove the unset it still wouldn''t work. So I just assumed that the php tags in javascript aren''t functioning right, did I do anything wrong or is php isn''t workable in javascript ? If it isn''t how could I do this function script ?
这篇关于php标签不适用于我的javascript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!