Home > Backend Development > PHP Tutorial > mysql - php如何显示session的内容

mysql - php如何显示session的内容

WBOY
Release: 2016-06-06 20:10:15
Original
914 people have browsed it

在session中保存了$_SESSION['nickName']
在后来的菜单栏中,我想要显示用户的这个昵称

<code>if(isset($_SESSION["userId"])){
    echo $_SESSION["nickName"];
} </code>
Copy after login
Copy after login

如何能添加HTML代码,让他用类似

$_SESSION["nickName"]
的格式来显示

回复内容:

在session中保存了$_SESSION['nickName']
在后来的菜单栏中,我想要显示用户的这个昵称

<code>if(isset($_SESSION["userId"])){
    echo $_SESSION["nickName"];
} </code>
Copy after login
Copy after login

如何能添加HTML代码,让他用类似

$_SESSION["nickName"]
的格式来显示

答案是{}大括号

<code><?php echo {$SESSION["nickname"]}
?>
</code>
Copy after login

我不懂,这个问题解决不了,我找到了,所以我Share出来,我说话不好听因为有人明明错了还出言不逊,难道你牛逼你就能瞧不起初学者,更何况,好像您水平一般吧?叫一群人来给负面评价什么的我都无所谓,你爱怎样怎也不会影响我,我是来学习不是来吵架的,己所不欲勿施于人不懂?

先学好基础再写代码。

<code>if(isset($_SESSION["userId"])) {
    echo $_SESSION["nickName"];
}</code>
Copy after login
Copy after login

直接这样:

<code>if(isset($_SESSION["userId"])){     
    echo {$_SESSION["nickName"]; 
} </code>
Copy after login

为啥还要加单引号啊?

<code>if(isset($_SESSION["userId"])) {
    echo $_SESSION["nickName"];
}</code>
Copy after login
Copy after login

亲,你加了''就意味着输出的是字符串.你去掉''之后才是SESSION变量

现在的人提问越来越牛逼了

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template