包含文件中的PHP定义值丢失

I have a config.php file with this line in it:

define("home_dir",'soft06/site_name');

In index.php file I have:

include_once ("config.php")
... some html code ....
include_once (home_dir."/footer.php")

That works well. However if in footer.php I put this line:

echo("home_dir=".home_dir);

I get:

Notice:  Use of undefined constant home_dir - assumed 'home_dir' in <b>D:\xampp\htdocs\footer.php on line 3
home_dir=home_dir

But if I choose to include footer.php like this: include_once ("footer.php") instead of include_once (home_dir."/footer.php") It works fine.

It seems to me that if I use the constant home_dir in include_once function I will lose the home_dir value within the include file.

Any help would be appreciated.

So you

include_once (home_dir."/footer.php")

trying to include file over http :^ ) And it have been executed before inclusion. So footer.php running in another http request and there for home_dir was not defined.

You must use local path for including.