please click here for more wordpress cource
In PHP, there are two types of constants:
- Defined Constants: These are constants that are defined using the
define()
function. Once defined, these constants cannot be changed or undefined during the execution of the script. The syntax for defining a constant is: sql Copy codedefine(name, value, case-insensitive)
Wherename
is the name of the constant,value
is the value assigned to the constant, andcase-insensitive
is an optional parameter that indicates whether the constant should be case-insensitive or not. - Magic Constants: These are predefined constants that are available in PHP at all times. These constants are called “magic” because they are automatically set by PHP based on the context in which they are used. For example, the
__LINE__
constant represents the current line number of the script, and the__FILE__
constant represents the full path and filename of the script. Some common magic constants include:__LINE__
__FILE__
__DIR__
__FUNCTION__
__CLASS__
__TRAIT__
__METHOD__
__NAMESPACE__