This article illustrates the use of get_defined_constants functions in PHP. Share to everyone for your reference. The specific analysis is as follows:
Get_defined_constants (php 4 > = 4.1.0, php 5)
Get_defined_constants-Returns an associative array of names of all constants and their values
Describe
Array Get_defined_constants ([Boolean $ collation])
Returns all the currently defined constants for the name and value. This includes the established extensions and the Define () functions created.
Parameters
Classification
Causes this function to return the first peacekeeping constant in the multidimensional array category and the second aspect of their values.
<?php
define ("My_constant", 1);
Print_r (Get_defined_constants (true));
? > The
above example'll output something similar to:
array
(
[internal] => array
(
[e_ ERROR] => 1
[e_warning] => 2
[E_parse] => 4
[E_notice] => 8
[E_core_error] => 16
[e_core_warning] =>
[E_compile_error] =>
[e_compile_warning] => 128
[E_user_error] => 256
[e_user_warning] = >
[e_user_notice] => 1024
[E_all] => 2047
[TRUE] => 1]
[pcre] => Array
(
[Preg_pattern_order] => 1
[Preg_set_order] => 2
[preg_offset_capture] => 256
[ Preg_split_no_empty] => 1
[preg_split_delim_capture] => 2
[preg_split_offset_capture] => 4
[ Preg_grep_invert] => 1
)
[user] => Array
(
[my_constant] => 1
)
)
I hope this article will help you with your PHP program design.