开发者

What is the meaning of the "Use of undefined constant" notice in PHP? [duplicate]

This question already has answers here: What does the PHP error message "Notice: Use of undefined constant" mean? 开发者_运维知识库 (2 answers) Closed 9 years ago.
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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜