Reputation: 673
Hi I have the following code and get the error even if i check if the variable is exist , why the php throw error? , how can I check it without error
if(!defined (ENV)){
define('ENV', getenv('ENV'));
};
( ! ) Notice: Use of undefined constant ENV - assumed 'ENV' in index.php on line 10
Upvotes: 0
Views: 262
Reputation: 612
You forgot to use quotes with the defined function. It should look like this.
if(!defined ('ENV')){
define('ENV', getenv('ENV'));
};
And when you want to output it you can use it without quotes.
echo ENV;
Upvotes: 1