dismiss Step into the future! Click here to switch to the beta php.net site
downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | conferences | my php.net

search for in the

List of Resource Types> <Predefined Classes
[edit] Last updated: Fri, 28 Jun 2013

view this page in

Predefined Constants

Core Predefined Constants

These constants are defined by the PHP core. This includes PHP, the Zend engine, and SAPI modules.

PHP_VERSION (string)
The current PHP version as a string in "major.minor.release[extra]" notation.
PHP_MAJOR_VERSION (integer)
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 (integer)
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 (integer)
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 (integer)
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 (integer)
Available since PHP 5.2.7.
PHP_DEBUG (integer)
Available since PHP 5.2.7.
PHP_MAXPATHLEN (integer)
The maximum length of filenames (including path) supported by this build of PHP. Available since PHP 5.3.0.
PHP_OS (string)
PHP_SAPI (string)
The Server API for this build of PHP. Available since PHP 4.2.0. See also php_sapi_name().
PHP_EOL (string)
The correct 'End Of Line' symbol for this platform. Available since PHP 4.3.10 and PHP 5.0.2
PHP_INT_MAX (integer)
The largest integer supported in this build of PHP. Usually int(2147483647). Available since PHP 4.4.0 and PHP 5.0.5
PHP_INT_SIZE (integer)
Available since PHP 4.4.0 and PHP 5.0.5
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. Available since PHP 4.3.0.
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). Available since PHP 4.3.0
E_ERROR (integer)
Error reporting constant
E_WARNING (integer)
E_PARSE (integer)
E_NOTICE (integer)
E_CORE_ERROR (integer)
E_CORE_WARNING (integer)
E_COMPILE_ERROR (integer)
E_COMPILE_WARNING (integer)
E_USER_ERROR (integer)
E_USER_WARNING (integer)
E_USER_NOTICE (integer)
E_DEPRECATED (integer)
Available since PHP 5.3.0
E_USER_DEPRECATED (integer)
Available since PHP 5.3.0
E_ALL (integer)
E_STRICT (integer)
Available since PHP 5.0.0
__COMPILER_HALT_OFFSET__ (integer)
Available since PHP 5.1.0
TRUE (boolean)
See Booleans.
FALSE (boolean)
See Booleans.
NULL (boolean)
See Null.

See also: Magic constants.

Standard Predefined Constants

All constants from core extensions are defined in PHP by default.



List of Resource Types> <Predefined Classes
[edit] Last updated: Fri, 28 Jun 2013
 
add a note add a note User Contributed Notes Predefined Constants - [4 notes]
up
3
soywiz at gmail dot com
4 years ago
Another way to determine PHP_INT_MIN:

<?php
define
('PHP_INT_MIN', ~PHP_INT_MAX);
?>

It should work always:

MAX for 8bit-signed: 01111111
MIN for 8bit-signed: 10000000

In 32 bits:
php -r"echo (int)base_convert(str_repeat('1', 31), 2, 10) - PHP_INT_MAX;"
0
<?php echo ~(int)base_convert(str_repeat('1', 31), 2, 10); ?>
-2147483648
up
0
Yousha dot A at Hotmail dot com
5 months ago
PHP_EOL replacement for PHP < 5.0.2 :

<?php

# PHP < 5.0.2
if(!defined('PHP_EOL'))
{
    if(
stristr(PHP_OS, 'WIN')) define('PHP_EOL', "\r\n");
    elseif(
stristr(PHP_OS, 'DAR')) define('PHP_EOL', "\r");
    else
define('PHP_EOL', "\n");
}

?>
up
0
Volker
4 days ago
simple check for current OS:

<?php

class System {

    const
OS_UNKNWON = 1;
    const
OS_WIN = 2;
    const
OS_LINUX = 3;
    const
OS_OSX = 4;

   
/**
     * @return int
     */
   
static public function getOS() {
        switch (
true) {
            case
stristr(PHP_OS, 'WIN'): return self::OS_WIN;
            case
stristr(PHP_OS, 'DAR'): return self::OS_OSX;
            case
stristr(PHP_OS, 'LINUX'): return self::OS_LINUX;
            default : return
self::OS_UNKNWON;
        }
    }

}

?>
up
0
j dot westfield at pmtsolutions dot eu
18 days ago
I am using PHP version 5.2.14, and PHP_OS is empty on my Windows / Apache - Setup.
Any notes on this? Many thanks.

 
show source | credits | stats | sitemap | contact | advertising | mirror sites