PDA

View Full Version : Notice: Use of undefined constant main - assumed 'main' in c:\xampp\htdocs\mysite


ldeky
09-13-2006, 10:02 AM
i'm use fast template,
i always see this message :
Notice: Use of undefined constant main - assumed 'main' in c:\xampp\htdocs\mysite\index.html on line 30

how to hide a message?


29 $ft = new FastTemplate( TEMPLATE_PATH );
30 $ft->define( array( main=>"index.html") );
31 $ft->assign( "INDEX_URL", INDEX_URL );
32 $ft->parse( mainContent, main );
33 $ft->FastPrint();

marek_mar
09-13-2006, 11:17 AM
The array indexes should be in quotes.
30 $ft->define( array( 'main'=>"index.html") );
... and everywhere else. If it's not in quote PHP assumes that it is a constant and when it finds out that the constant doesn't exist it assumes it's value is it's name (and gives an error notice).

NancyJ
09-13-2006, 09:01 PM
to hide notices set your error reporting to E_ERROR

...just for future reference, as marek_mar says, the notice is telling something important. PHP is pretty good at trying to figure out what you mean and will try to use it as a string if it cant find a constant - but even so you should put quotes around strings that you mean to be strings not constants

marek_mar
09-13-2006, 09:04 PM
Some of these notices will become errors in PHP6... hiding notices is not a good thing to do.

NancyJ
09-13-2006, 09:09 PM
Thats a matter of opinion, preference and nature of your application.
We hide all errors on production sites - better for it to fail silently than to show your oops to customers.

Some notices are just downright annoying - usually about unintialised variables - essentially rendering isset() a pointless function.

marek_mar
09-13-2006, 09:18 PM
... isset() isn't even a function... and it is very usefull as only isset() and empty() don't give notices on uninitialized variables.