Where Exactly Yii_Debug Is Defined?

(this is a copy of this Stack Overflow question, so please, feel free to answer there, if you have an account at SO and would like to gain some rep for answering)

I have a standard (auto-generated) index.php bootstrap file for my Yii application. It contains:

defined('YII_DEBUG') or define('YII_DEBUG', TRUE);

defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL', 3);

When I put these two lines:



below definition of these two Yii constants, I’m getting an excepted behavior (two times true).

When I comment first line of first code block (YII_DEBUG definition) I’m also getting an expected results – false + Notice: Use of undefined constant YII_DEBUG.

Strange things starts to happen, when I leave definition of YII_DEBUG commented, but move these two var_dump lines from index.php and put them in the beginning of my configuration file.

I expected the very same behavior (nothing has changed, YII_DEBUG remains undefined), but instead I’m getting true + false.

What has happened? What I’m missing? At which point of Yii application life-cycle the YII_DEBUG constant has become defined?

(adding print_r(get_defined_constants(true)[‘user’]); below these two var_dump confirms, that YII_DEBUG is defined in second scenario and undefined in first one)

Already got an answer – whoa, that was fast (thank Michiel):

[i]YII_DEBUG is set to false in YiiBase.php, that gets called by yii.php, that is included in your index.php.

[/i]All the glory, for answering this question, goes to Michel, not me!