>  기사  >  백엔드 개발  >  使用unset()时出现的异常如何解决

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

WBOY
WBOY원래의
2016-06-13 10:34:53887검색

使用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);?>


为什么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 后面的语句你是用来测试的吧? 那出现这个提示就对了,不出现这个提示反而不正确。
성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.