I\'ve noticed that frequently people simply write
while I have been using:
In PHP, if a variable does not exist (is "unset") then PHP will spit out an E_NOTICE
error, create the missing variable, and assign it to NULL
.
If you do not want your scripts filled with annoying error messages that leak information about your server and script - then use isset()
to test before trying to access a value.
Basically, you're asking PHP to get username
out of $_SESSION
and PHP is like, "there is no username
"!