RE: [PHP] Advice on Constants - Notice: Undefined Constant

From: Date: Wed, 09 Apr 2003 18:26:22 +0000
Subject: RE: [PHP] Advice on Constants - Notice: Undefined Constant
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-143138@lists.php.net to get a copy of this message
Hi, If a constant is defined, then that notice should not be coming. A constant and a variable can have the same name, but are entirely different entities. $puks = 20; define(puks, 10); echo puks.'\n'.$puks; will print : 10 20 And incase you are getting undefine notices, then it only means that for the execution of the script, the variable or the constant is/are undefined. --- Adam Douglas <ADouglas@venmarces.com> wrote: > > Notices are generated when you have > error_reporting in > > your php.ini set to E_ALL & ~E_NOTICE > > > > Notices can be helpful at times, but on production > > sites, generally donot help, because hidden input > form > > fields (not yet set), can show up as undefined. > > > > As regarding to your question, the constant is > defined > > and replaced internally in all your places in your > php > > script. > > > > Incase you want to store a constant value > dynamically > > you need to call a function called "constant", > which > > returns the value of a constant. > > > > http://in.php.net/manual/en/function.constant.php > > > > As for the NOTICE of an undefined offset, > indicates > > that the array element is not present. > > Yes I'm aware of all the bases regarding the notices > and I am aware of the > constant function. What I was asking what is the > best way to resolve my > situation? I want to do proper coding to the best of > my ability. So even > with your remark about forms with hidden fields, I > agree but can this not be > resolved? Maybe doing a define(variable, 0). > > I'm just looking for direction and the best > solution. I assume that these > notices are nothing major but should not be > occurring if I would have done > things correctly. Is this correct? > > Or should I be taking the notices as just a notice > to let me know and that > my code is fine? ===== ********************************* Know more about me: http://www.geocities.com/mimodit ********************************* __________________________________________________ Do you Yahoo!? Yahoo! Tax Center - File online, calculators, forms, and more http://tax.yahoo.com

« previous php.general (#143138) next »