检查是否存在define变量 - php中的警告错误

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

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;