简体   繁体   中英

Define CONSTANT not working, why?

I've defined on config.php:

define('ROOT', __DIR__);

and on index.php:

require_once (ROOT.'/header.php');

result:

Notice: Use of undefined constant ROOT - assumed 'ROOT'

Why ROOT constant isn't working? I'm learning, someone could explain me?

EDIT

If I put:

require_once (__DIR__.'/header.php');

It works. Someone could explain me why?

It wasn't working cause ROOT was defined inside 'header.php'.

It needs to be defined before call header.php.

Thanks for any help.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM