Home > Backend Development > PHP Tutorial > php中get_defined_constants函数用法实例分析_PHP

php中get_defined_constants函数用法实例分析_PHP

WBOY
Release: 2016-06-01 11:05:49
Original
855 people have browsed it

本文实例讲述了php中get_defined_constants函数用法。分享给大家供大家参考。具体分析如下:

get_defined_constants ( PHP 4中 > = 4.1.0 , PHP 5中)

get_defined_constants -返回一个关联数组的名字所有的常量和他们的价值观

描述

阵列get_defined_constants ( [布尔$归类] )

返回名称和值的所有当前定义的常量。这包括设立的扩展以及创建的define()函数。

参数

分类

造成这个函数返回多维阵列类别中的第一项维和常量和他们的价值观中的第二个方面。

<&#63;php
define("MY_CONSTANT", 1);
print_r(get_defined_constants(true));
&#63;> 
The above example will 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] => 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
    )
)
Copy after login

希望本文所述对大家的php程序设计有所帮助。

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template