defined('YII_DEBUG') question

Hi,

In my application layout, I have this code:


if (!defined('YII_DEBUG')) {

echo '<meta http-equiv="refresh" content="180;url='

  . (isset($_SERVER["HTTPS"]) ? 'https://' : 'http://')

  . $_SERVER['SERVER_NAME'] . Yii::app()->urlManager->createUrl('site/logout')

  . '" />';

}

So, depending the value of YII_DEBUG, if it’s not defined in the entry script index.php, I send a meta refresh tag to logout the user after 180 seconds. Otherwise (development server), it should not be displayed.

However, this does not work. It doesn’t matter if I have YII_DEBUG commented or not in the index.php file, defined(‘YII_DEBUG’) always returns true. This is probably a PHP issue, but I would appreciate any help.

Thanks.


if (YII_DEBUG)

seems to work fine. I searched through Yii’s codebase and this is how YII_DEBUG is used.

However, I still think defined() should work.

YII_DEBUG is always defined (in YiiBase.php). Its value could be either true or false.

Ahhh… Thanks for the explanation. That’s why defined didn’t work the way I expected. Thanks!