是什么导致了这个未定义的常量错误?

时间:2014-01-11 16:51:48

标签: php

我有以下未定义的常量错误:

test.php的:

Notice: Use of undefined constant APP_ID - assumed 'APP_ID' in 
/var/www/_calls/config.php on line 3 

相关代码行:

test.php的:

require_once('config.php');

的config.php:

define(APP_ID, 'Your app name');

2 个答案:

答案 0 :(得分:3)

使用字符串定义常量。您不能使用常量来定义常量,因为尚未定义常量:

define('APP_ID', 'Your app name');

只有在您定义常量后,才能将其称为APP_ID而不是'APP_ID'

请参阅define,该{{3}}接受string $name , mixed $value...

答案 1 :(得分:1)

使用此

 define('APP_ID', 'Your app name');
相关问题