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?
You cannot unset constants. They exists until removed from the source code.
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?
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.
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?
Thanks again.