使用unset()时出现的异常如何解决

WBOY
Release: 2016-06-13 10:34:53
Original
918 people have browsed it

使用unset()时出现的错误怎么解决

PHP code
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--><?php ob_start('ob_gzhandler');            session_save_path('2;D:/sessionFile/sessionFile');    @session_start();                    $_SESSION["username"] = 'jason';    $user = $_SESSION["username"];        printf("Your username is %s.<br />", $user);        unset($user);    printf("Username now set to: %s<br>", $user);?>
Copy after login


为什么unset()时显示Notice: Undefined variable: user in D:\Apache Group\Apache2\htdocs\PHPProject\index3.php on line 30:


发现关于session的函数多少都会有些错误提示的。。。

------解决方案--------------------
sorry我没细看你的代码!
unset($user); // 这将从变量表中清除名为user的变量,因此下一句代码就会出现$user未定义,你不会连unset()是什么都不知道吧?
printf("Username now set to: %s
", $user);
------解决方案--------------------
unset 后面的语句你是用来测试的吧? 那出现这个提示就对了,不出现这个提示反而不正确。
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