PHP Function Get_Defined_Constants()
A constant is a value that will not change at runtime and can be accessed with its name. Unlike variables, which can be defined and undefined with ease, constants are hard-coded into your script at compile time using the define() function or the const keyword. PHP also allows for defining constants using the final keyword, though the resulting constants will be revealed at runtime, not at compile time.
Whether you use the define() or const methods, PHP has a built-in function that will return a list of all your constants in an array: get_defined_constants(). The function takes a boolean argument to categorize your constants (default is false). If it’s not set, then the get_defined_constants() will simply dump all user-defined and core constants into an associative array with their names in one dimension and their values in another.
Names for constants should be uppercase and follow standard variable naming rules. They can start with any letter or underscore, then be followed by letters or numbers. They can also be preceded by any of the PHP built-in constants, but it is preferable to use descriptive names for your own constants.
As of PHP 8.0.0, if a constant is not defined it will raise an error at runtime, instead of being interpreted as a bare word string like in previous versions of the language. This is an important security feature that should be utilized in all of your projects to ensure you can always trust the values being used.