I am having a bit of trouble setting and using environment variables in PHP.
I have a php file as follows
http://localhost/site/include.php
<?php
define("ENV_LOCATION", "http://localhost/site/resources/addition");
?>
Which I am including in the following file
http://localhost/site/home.php
<html>
<?php
include("include.php");
?>
<body>
<?php
// this bit works
echo ENV_LOCATION;
// this bit works
include(ENV_LOCATION . "/test.php");
?>
</body>
</html>
but then it seems to lose the environment variable when I try to use it in the last file I am including
http://localhost/site/resources/addition/test.php
<?php
// this fails
echo ENV_LOCATION;
?>
Why is this file unable to see the environment variable? I am getting the following error
Notice: Use of undefined constant ENV_LOCATION - assumed 'ENV_LOCATION' in /var/www/html/site/resources/addition/test.php on line 3
ENV_LOCATION