定义 CONSTANT 不起作用,为什么?
Define CONSTANT not working, why?
我在 config.php 上定义:
define('ROOT', __DIR__);
以及 index.php:
require_once (ROOT.'/header.php');
结果:
Notice: Use of undefined constant ROOT - assumed 'ROOT'
为什么 ROOT 常量不起作用?我正在学习,有人可以解释我吗?
编辑
如果我输入:
require_once (__DIR__.'/header.php');
有效。有人可以解释一下为什么吗?
它不起作用,因为 ROOT 是在 'header.php'.
中定义的
需要在调用前定义header.php。
感谢您的帮助。
我在 config.php 上定义:
define('ROOT', __DIR__);
以及 index.php:
require_once (ROOT.'/header.php');
结果:
Notice: Use of undefined constant ROOT - assumed 'ROOT'
为什么 ROOT 常量不起作用?我正在学习,有人可以解释我吗?
编辑
如果我输入:
require_once (__DIR__.'/header.php');
有效。有人可以解释一下为什么吗?
它不起作用,因为 ROOT 是在 'header.php'.
中定义的需要在调用前定义header.php。
感谢您的帮助。