PHP: undefined constant while defining it
I'm getting the following error in PHP:
Notice: Use of undefined constant CONSTANT
on the exact line where I define it:
define(CONSTANT, true);
What am I doing wrong? I defined it, so why does it say "Undefined constant"?
你需要引用成为常量的字符串
define('CONSTANT', true);
The best way to understand what are you doing wrong is to read PHP manual.
Here is definition of define function.
bool define ( string $name , mixed $value [, bool $case_insensitive = false ] )
So the first argument must be a string.
If you write it like that you are using the value of an already defined constant as a constant name.
What you want to do is to pass the name as a string:
define('CONSTANT', true);
链接地址: http://www.djcxy.com/p/69258.html
上一篇: basedir限制奇怪
下一篇: PHP:在定义它时未定义常量