Home > Backend Development > PHP Tutorial > 《php和MySQL Web开发》第23章在php中使用对话控制,遇到难题卡壳了

《php和MySQL Web开发》第23章在php中使用对话控制,遇到难题卡壳了

WBOY
Release: 2016-06-13 12:25:14
Original
929 people have browsed it

《php和MySQL Web开发》第23章在php中使用会话控制,遇到难题卡壳了~

<?php<br />	session_start();<br />	<br />	$_SESSION_[ 'sess_var'] = "Hello World";<br />	echo $_SESSION[ 'sess_var'];<br /><br />	echo 'The content of $_SESSION[\'sess_var\'] is '.$_SESSION[ 'sess_var'].'<br />';<br />	<br />?>
Copy after login

运行结果:
The content of $_SESSION['sess_var'] is 
为什么$_SESSION_[ 'sess_var']没有打印出来,是session已经失效了么?
------解决思路----------------------
你是
这样赋值 $_SESSION_[ 'sess_var'] = "Hello World";
这样使用 echo $_SESSION[ 'sess_var'];


难道你认为 $_SESSION_ 和 $_SESSION 是一个东西吗?

应让 php 检查全部错误(令 php.ini 中 error_reporting = E_ALL),这样 php 就会告诉你哪些地方有问题了
------解决思路----------------------
session_start();
$_SESSION_[ 'sess_var'] = "Hello World";
var_dump($_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