I would like to use constants as configuration variables in my PHP applications only when the constant does not exist (for some reason) it throws me a notification, but I would like it to be an error (or exception), just like when I try to repeat a non existing variable.
This is possible without using a separate function to get constant values, something like this:
echo $non_existing_variable;
echo NON_EXISTING_CONSTANT;
I searched a little, but could not find anything.
It seems logical to me when I try to use a variable that does not exist, the execution of the code immediately terminates and throws an error, why is this not the case with constants?
Stefan
source
share