RE: [PHP] Advice on Constants - Notice: Undefined Constant
| From: | Adam Douglas | Date: | Wed, 09 Apr 2003 18:04:42 +0000 |
| Subject: | RE: [PHP] Advice on Constants - Notice: Undefined Constant | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-143133@lists.php.net to get a copy of this message | ||
> 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?