如何在php会话文件中包含jQuery文件?
这是我的php文件,它在其中为用户创建会话:-如何在php会话文件中包含jQuery文件?,php,jquery,session,Php,Jquery,Session,这是我的php文件,它在其中为用户创建会话:- <?php //starting the session session_start(); //checking if session of user is set ot not if(isset($_SESSION['UID'])) { echo "Welcome, ".$_SESSION['UID']; } else { header("Location:
<?php
//starting the session
session_start();
//checking if session of user is set ot not
if(isset($_SESSION['UID'])) {
echo "Welcome, ".$_SESSION['UID'];
}
else {
header("Location: ErrorPage.html");
}
?>
我希望在用户登录后隐藏我的“#链接”。如何在php中的if语句中包含jQuery文件?我试过:-
include("jqueryFile.js");
require("jqueryFile.js");
但它不起作用。您必须输出该文件(准备部署到客户端)
if(isset($\u会话['uid'])){
?>
隐藏();
您必须输出该文件(准备部署到客户端)
if(isset($\u会话['uid'])){
?>
隐藏();
Require和include用于服务器端文件,如php
你应该做一些简单的事情,比如
echo '<script type="text/javascript" src="jqueryFile.js"></script>';
echo';
如果要使用require/include命令,应该将javascript存储在.php文件中
require('jqueryFile.php')
;require和include用于服务器端文件,如php
你应该做一些简单的事情,比如
echo '<script type="text/javascript" src="jqueryFile.js"></script>';
echo';
如果要使用require/include命令,应该将javascript存储在.php文件中
require('jqueryFile.php')
;
您可以做得比这更好您可以做得比这更好为什么要使用javascript来完成可以通过CSS完成的事情?如果用户以“隐藏”和CSS写入的方式登录,您只需分配CSS类即可。隐藏{display:none;}。然而,更好的方法可能是有两个模板:一个是带有登录用户菜单的模板,另一个是带有未登录用户菜单的模板。为什么要使用javascript来完成可以通过CSS完成的事情?如果用户以“隐藏”和CSS写入的方式登录,则只需分配CSS类即可。隐藏{display:none;}。然而,更好的方法可能是有两个模板:一个带有登录用户菜单,另一个带有未登录用户菜单。
echo '<script type="text/javascript" src="jqueryFile.js"></script>';
<?php if (isset($_SESSION['uid'])) { ?>
<script type="text/javascript" src="jqueryFile.js"></script>
<?php } ?>