Php/docs/reserved.constants

来自菜鸟教程
跳转至:导航、​搜索

预定义常量

内核预定义常量

这些常量在 PHP 的内核中定义。它包含 PHP、Zend 引擎和 SAPI 模块。

PHP_VERSION (string)
The current PHP version as a string in "major.minor.release[extra]" notation.
PHP_MAJOR_VERSION (int)
The current PHP "major" version as an integer (e.g., int(5) from version "5.2.7-extra"). Available since PHP 5.2.7.
PHP_MINOR_VERSION (int)
The current PHP "minor" version as an integer (e.g., int(2) from version "5.2.7-extra"). Available since PHP 5.2.7.
PHP_RELEASE_VERSION (int)
The current PHP "release" version as an integer (e.g., int(7) from version "5.2.7-extra"). Available since PHP 5.2.7.
PHP_VERSION_ID (int)
The current PHP version as an integer, useful for version comparisons (e.g., int(50207) from version "5.2.7-extra"). Available since PHP 5.2.7.
PHP_EXTRA_VERSION (string)
The current PHP "extra" version as a string (e.g., '-extra' from version "5.2.7-extra"). Often used by distribution vendors to indicate a package version. Available since PHP 5.2.7.
PHP_ZTS (int)
Available since PHP 5.2.7.
PHP_DEBUG (int)
Available since PHP 5.2.7.
PHP_MAXPATHLEN (int)
The maximum length of filenames (including path) supported by this build of PHP. Available since PHP 5.3.0.
PHP_OS (string)
The operating system PHP was built for.
PHP_OS_FAMILY (string)
The operating system family PHP was built for. Either of 'Windows', 'BSD', 'Darwin', 'Solaris', 'Linux' or 'Unknown'. Available as of PHP 7.2.0.
PHP_SAPI (string)
The Server API for this build of PHP.参见 php_sapi_name()
PHP_EOL (string)
当前平台中对于换行符的定义。自 PHP 5.0.2 起可用
PHP_INT_MAX (int)
当前 PHP 版本支持的最大整型数字。在 32 位系统中通常为 int(2147483647),64 位系统中为 int(9223372036854775807)。自 PHP 5.0.5 起可用。
PHP_INT_MIN (int)
当前 PHP 版本支持的最大整型数字。在 32 位系统中通常为 int(-2147483648),64 系统中为 int(-9223372036854775808)。自 PHP 7.0.0 起可用。通常情况下 PHP_INT_MIN === ~PHP_INT_MAX。
PHP_INT_SIZE (int)
The size of an integer in bytes in this build of PHP. 自 PHP 5.0.5 起可用
PHP_FLOAT_DIG (int)
Number of decimal digits that can be rounded into a float and back without precision loss. Available as of PHP 7.2.0.
PHP_FLOAT_EPSILON (float)
Smallest representable positive number x, so that x + 1.0 != 1.0. Available as of PHP 7.2.0.
PHP_FLOAT_MIN (float)
Smallest representable positive floating point number. If you need the smallest representable negative floating point number, use - PHP_FLOAT_MAX. Available as of PHP 7.2.0.
PHP_FLOAT_MAX (float)
Largest representable floating point number. Available as of PHP 7.2.0.
DEFAULT_INCLUDE_PATH (string)
PEAR_INSTALL_DIR (string)
PEAR_EXTENSION_DIR (string)
PHP_EXTENSION_DIR (string)
PHP_PREFIX (string)
The value "--prefix" was set to at configure.
PHP_BINDIR (string)
Specifies where the binaries were installed into.
PHP_BINARY (string)
Specifies the PHP binary path during script execution. Available since PHP 5.4.
PHP_MANDIR (string)
Specifies where the manpages were installed into. Available since PHP 5.3.7.
PHP_LIBDIR (string)
PHP_DATADIR (string)
PHP_SYSCONFDIR (string)
PHP_LOCALSTATEDIR (string)
PHP_CONFIG_FILE_PATH (string)
PHP_CONFIG_FILE_SCAN_DIR (string)
PHP_SHLIB_SUFFIX (string)
The build-platform's shared library suffix, such as "so" (most Unixes) or "dll" (Windows).
PHP_FD_SETSIZE (string)
The maximum number of file descriptors for select system calls. Available as of PHP 7.1.0.
E_ERROR (int)
Error reporting constant
E_WARNING (int)
Error reporting constant
E_PARSE (int)
Error reporting constant
E_NOTICE (int)
Error reporting constant
E_CORE_ERROR (int)
Error reporting constant
E_CORE_WARNING (int)
Error reporting constant
E_COMPILE_ERROR (int)
Error reporting constant
E_COMPILE_WARNING (int)
Error reporting constant
E_USER_ERROR (int)
Error reporting constant
E_USER_WARNING (int)
Error reporting constant
E_USER_NOTICE (int)
Error reporting constant
E_RECOVERABLE_ERROR (int)
Error reporting constant. Available since PHP 5.2.0
E_DEPRECATED (int)
Error reporting constant. Available since PHP 5.3.0
E_USER_DEPRECATED (int)
Error reporting constant. Available since PHP 5.3.0
E_ALL (int)
Error reporting constant
E_STRICT (int)
Error reporting constant
__COMPILER_HALT_OFFSET__ (int)
自 PHP 5.1.0 起有效
true (boolean)
See Booleans.
false (boolean)
See Booleans.
null (null)
See Null.
PHP_WINDOWS_EVENT_CTRL_C (int)
A Windows CTRL+C event. Available as of PHP 7.4.0 (Windows only).
PHP_WINDOWS_EVENT_CTRL_BREAK (int)
A Windows CTRL+BREAK event. Available as of PHP 7.4.0 (Windows only).

参见 魔术常量


标准预定义常量

所有在核心扩展 的常量是 PHP 默认定义的。