Grammar
Mixed constant (string $name)
Description
The constant () function returns the value of a constant. This function is particularly useful when you do not know the name of the constant beforehand, but need to get the value of the constant.
The value of the corresponding constant is obtained by passing the name of the constant to the $name parameter.
This function still applies to class constants.
return value
Returns the value of the constant, or null if the constant is undefined, but at this point a e_warning level error is generated.
Example
<?php define ("MAXSIZE", +); echo MAXSIZE; ECHO constant ("MAXSIZE"); Same thing as the previous line interface Bar { Const TEST = ' foobar! '; } class Foo { const TEST = ' foobar! '; } $const = ' test '; Var_dump (Constant (' Bar:: '. $const)); String (7) "foobar!" Var_dump (Constant (' foo:: '. $const)); String (7) "foobar!"
The above is the note 018 PHP constant () function content, more relevant content please pay attention to topic.alibabacloud.com (www.php.cn)!