Define CONSTANT not working, why?

1.6k views Asked by At

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?

1

There are 1 answers

0
Bibiana On BEST ANSWER

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

It needs to be defined before call header.php.

Thanks for any help.