What is the meaning of the "Use of undefined constant" notice in PHP? [duplicate]
Notice: Use of undefined constant username - assumed 'username' in
/home/content/04/7195304/html/header.php on line 54
I get this when writing things like $_COOKIE[username]
or $_POST[username]
.
Edit
So I've been playing around with the code, putting quotes in my POST, COOKIE, and GET's.. I still get the same thing!
It means you likely forgot a $ in front of your variable name.
Edit You need to encapsulate your call in qoutes. I.e.
$_COOKIE["username"]
or
$_POST["username"]
It probably means you forgot to put a $
in front of your username
variable, so it's treating it like a constant instead of a variable.
You should post the code from that line for better help.
You might as well try $_COOKIE['username'] or $_POST['username'], to access the associative arrays with a string.
Sorry, overlooked comment with same advice.
精彩评论