Undefine a constant?


Is it possible to undefine (or redefine would also work) a constant?

um, I don’t think so. But if you really need to change or delete a constant, you may want to reconcider what you are using it for. Constants are just that: constant. They are never saposed to change. Just as well, a variable is just that: variable. If the value is ever saposed to change, then it is a variable.

Ya, I know that.

And I know that the “official” word is that it can’t be done in PHP.

My situation is that an external library defines a constant that I use in my applications. I know I could just go through and change it’s name to avoid conflicts, but this raised more of a theoretical question :slight_smile:

Wait until the script is finished executing. :slight_smile:

Once a constant is defined you are unable to re-define or un-define it. There is no way I know of to go around this.

From the PHP manual:

Once a constant is defined, it can never be changed or undefined.