Use the defined function
defined(String constants_name)
If the constant exists, return bool(true)
If it does not exist, return bool(false)
The above introduces how PHP determines whether a constant is defined? , including relevant content, I hope it will be helpful to friends who are interested in PHP tutorials.