bostboy — 2011-04-13T00:56:54-04:00 — #1
Just a quick question to verify. The useful life of a declared constant is until you unset it or until the end of the script, correct?
logic_earth — 2011-04-13T01:09:46-04:00 — #2
You cannot unset constants. They exists until removed from the source code.
bostboy — 2011-04-13T01:31:09-04:00 — #3
By removed from the source code, do you mean until the script finishes execution? They don't act like session variables, correct? So if I issue a "header('Location: ..." I lose access to it?
logic_earth — 2011-04-13T01:36:21-04:00 — #4
A constant never changes the constant is always there. If the script that has the constant no longer exists or is not running then the constant cannot be accessed. But no they are not session variables not that it would matter. Constants are readonly values set in the source code for shortcuts.
bostboy — 2011-04-13T01:52:19-04:00 — #5
I appreciate the input. I think I got it.
Just out of curiousity, from a best practices standpoint, why or when would you use a constant as opposed a regular variable. In effect, a constant is just a variable that you are not going to change, correct? I understand it is a cleaner coding standard and better case of typing, any other advantages?