TYPO3:何时/如何使用define('TYPO3_MODE','FE');

/public_html/demo is my TYPO3 site, i put a test.php file under it,

<?php
//define('TYPO3_MODE','FE');

require('typo3conf/localconf.php');
require('t3lib/class.t3lib_db.php');
require('t3lib/class.t3lib_div.php');

define('TYPO3_db_host', $typo_db_host);
define('TYPO3_db_username', $typo_db_username);
define('TYPO3_db_password', $typo_db_password);
define('TYPO3_db', $typo_db);


$DB = new t3lib_DB();
$DB->connectDB();
$result = mysql_query("SELECT * FROM fe_users WHERE username='tom_seeker'");
while($row = mysql_fetch_array($result))
{
    echo $row['email'];
}

?>

Question:

when need to put this line: define('TYPO3_MODE','FE');? Here i comment it out, and script still works, so i just wonder when/how to use define('TYPO3_MODE','FE');?

There should be no need to define this constant. TYPO3 will do it for you.

Either build a plugin you can put on your site, or an eID that does not need a site to function. Both will give you the TYPO3 environment; the plugin a full one, the eID a smaller (and faster) one.

Normally you define the TYPO3_MODE to tell the system if you are in the Frontend or Backend (FE vs BE).

Many Extensions ask the state of TYPO3_MODE.

if (!defined ('TYPO3_MODE'))    die ('Access denied.');