gpt4 book ai didi

javascript - JS 与 PHP : if/else

转载 作者:行者123 更新时间:2023-11-28 16:35:49 26 4
gpt4 key购买 nike

我可以这样做吗?:

$(window).focus(function() {
<?php if(session....) ?>
...$.ajax...
<?php }else{
header('');
}
?>
});

最佳答案

是的,可以,但请记住,PHP if-else 在服务器上执行并且仅执行一次,因此生成的 JS 将包含 $.ajax > 调用或什么都不做 - 一旦页面加载,这将不会改变。

此外,在发送了一些输出后,您通常不能调用 header(除非您使用输出缓冲)。

关于javascript - JS 与 PHP : if/else,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4126742/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com