当前位置: 移动技术网 > IT编程>开发语言>PHP > PHP中 get_defined_constants() 获取所有常量

PHP中 get_defined_constants() 获取所有常量

2020年04月16日  | 移动技术网IT编程  | 我要评论

定义

get_defined_constants — 以关联数组形式获取所有常量

用法

get_defined_constants ([ bool $categorize = false ] ) : array

返回所有常量,包括内置、扩展或自定义。
categorize 决定是否分类。默认不分类。


示例

<?php
  define("my_constant", 1);
  print_r(get_defined_constants(true));
?>

输出:

array
(
    [core] => array
        (
            [e_error] => 1
            [e_warning] => 2
            [e_parse] => 4
            [e_notice] => 8
            [e_core_error] => 16
            [e_core_warning] => 32
            [e_compile_error] => 64
            [e_compile_warning] => 128
            [e_user_error] => 256
            [e_user_warning] => 512
            [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
        )

)

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网