PHP Options&Information PHP Options/Info assert Checks if assertion is &false; Description intassert string|boolassertion assert will check the given assertion and take appropriate action if its result is &false;. If the assertion is given as a string it will be evaluated as PHP code by assert. The advantages of a string assertion are less overhead when assertion checking is off and messages containing the assertion expression when an assertion fails. Assertions should be used as a debugging feature only. You may use them for sanity-checks that test for conditions that should always be &true; and that indicate some programming errors if not or to check for the presence of certain features like extension functions or certain system limits and features. Assertions should not be used for normal runtime operations like input parameter checks. As a rule of thumb your code should always be able to work correctly if assertion checking is not activated. The behavior of assert may be configured by assert_options or by .ini-settings described in that functions manual page. The assert_options function and/or ASSERT_CALLBACK configuration directive allow a callback function to be set to handle failed assertions. assert callbacks are particularly useful for building automated test suites because they allow you to easily capture the code passed to the assertion, along with information on where the assertion was made. While this information can be captured via other methods, using assertions makes it much faster and easier! The callback function should accept three arguments. The first argument will contain the file the assertion failed in. The second argument will contain the line the assertion failed on and the third argument will contain the expression that failed (if any - literal values such as 1 or "two" will not be passed via this argument) Handle a failed assertion with a custom handler Assertion Failed: File '$file'
Line '$line'
Code '$code'

"; } // Set up the callback assert_options (ASSERT_CALLBACK, 'my_assert_handler'); // Make an assertion that should fail assert ('mysql_query ("")'); ?> ]]>
assert_options Set/get the various assert flags Description mixedassert_options intwhat mixedvalue Using assert_options you may set the various assert control options or just query their current settings. Assert Options option ini-parameter default description ASSERT_ACTIVE assert.active 1 enable assert evaluation ASSERT_WARNING assert.warning 1 issue a PHP warning for each failed assertion ASSERT_BAIL assert.bail 0 terminate execution on failed assertions ASSERT_QUIET_EVAL assert.quiet_eval 0 disable error_reporting during assertion expression evaluation ASSERT_CALLBACK assert_callback (&null;) user function to call on failed assertions
assert_options will return the original setting of any option or &false; on errors.
extension_loaded Find out whether an extension is loaded Description boolextension_loaded stringname Returns &true; if the extension identified by name is loaded. You can see the names of various extensions by using phpinfo. See also phpinfo. This function was added in 3.0.10. dl Loads a PHP extension at runtime Description intdl stringlibrary Loads the PHP extension defined in library. See also the Extension Loading Directives getenv Gets the value of an environment variable Description stringgetenv stringvarname Returns the value of the environment variable varname, or &false; on an error. You can see a list of all the environmental variables by using phpinfo. You can find out what many of them mean by taking a look at the CGI specification, specifically the page on environmental variables. This function does not work in ISAPI mode. See also putenv. get_cfg_var Gets the value of a PHP configuration option Description stringget_cfg_var stringvarname Returns the current value of the PHP configuration variable specified by varname, or &false; if an error occurs. It will not return configuration information set when the PHP was compiled, or read from an Apache configuration file (using the php3_configuration_option directives). To check whether the system is using a configuration file, try retrieving the value of the cfg_file_path configuration setting. If this is available, a configuration file is being used. See also ini_get. get_current_user Gets the name of the owner of the current PHP script Description stringget_current_user Returns the name of the owner of the current PHP script. See also getmyuid, getmygid, getmypid, getmyinode, and getlastmod. get_defined_constants Returns an associative array with the names of all the constants and their values Description arrayget_defined_constants This function returns the names and values of all the constants currently defined. This includes those created by extensions as well as those created with the define function. For example the line below will print a list like: 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 ) ]]> See also get_loaded_extensions, get_defined_functions and get_defined_vars. get_extension_funcs Returns an array with the names of the functions of a module Description arrayget_extension_funcs stringmodule_name This function returns the names of all the functions defined in the module indicated by module_name. For example the lines below will print a list of the functions in the modules xml and gd respectively. See also: get_loaded_extensions getmygid Get PHP script owner's GID Description intgetmygid Returns the group ID of the current script, or &false; on error. See also getmyuid, getmypid, get_current_user, getmyinode, and getlastmod. get_included_files Returns an array with the names of included or required files Description arrayget_included_files Returns an array of the names of all files that have been included using include, include_once, require or require_once. Files that are included or required multiple times only show up once in the returned array. Files included using the auto_prepend_file configuration directive are not included in the returned array. <function>get_included_files</function> Example ]]> will generate the following output: In PHP 4.0.1pl2 and previous versions get_included_files assumed that the required files ended in the extension .php; other extensions would not be returned. The array returned by get_included_files was an associative array and only listed files included by include and include_once. See also: include, include_once, require, require_once, and get_required_files. get_loaded_extensions Returns an array with the names of all modules compiled and loaded Description arrayget_loaded_extensions This function returns the names of all the modules compiled and loaded in the PHP interpreter. For example the line below will print a list like: xml [1] => wddx [2] => standard [3] => session [4] => posix [5] => pgsql [6] => pcre [7] => gd [8] => ftp [9] => db [10] => Calendar [11] => bcmath ) ]]> See also: get_extension_funcs. get_magic_quotes_gpc Gets the current active configuration setting of magic quotes gpc Description longget_magic_quotes_gpc Returns the current active configuration setting of magic_quotes_gpc (0 for off, 1 for on). See also get_magic_quotes_runtime and set_magic_quotes_runtime. get_magic_quotes_runtime Gets the current active configuration setting of magic_quotes_runtime Description longget_magic_quotes_runtime Returns the current active configuration setting of magic_quotes_runtime (0 for off, 1 for on). See also get_magic_quotes_gpc and set_magic_quotes_runtime. getlastmod Gets time of last page modification Description intgetlastmod Returns the time of the last modification of the current page. The value returned is a Unix timestamp, suitable for feeding to date. Returns &false; on error. getlastmod() example See also date, getmyuid, getmygid, get_current_user, getmyinode, and getmypid. getmyinode Gets the inode of the current script Description intgetmyinode Returns the current script's inode, or &false; on error. See also getmygid, getmyuid, get_current_user, getmypid, and getlastmod. ¬e.no-windows; getmypid Gets PHP's process ID Description intgetmypid Returns the current PHP process ID, or &false; on error. Process IDs are not unique, thus they are a weak entropy source. We recommend against relying on pids in security-dependent contexts. See also getmygid, getmyuid, get_current_user, getmyinode, and getlastmod. getmyuid Gets PHP script owner's UID Description intgetmyuid Returns the user ID of the current script, or &false; on error. See also getmygid, getmypid, get_current_user, getmyinode, and getlastmod. get_required_files Returns an array with the names of included or required files Description arrayget_required_files As of PHP 4.0.4, this function is an alias for get_included_files In PHP 4.0.1pl2 and previous versions get_required_files assumed that the required files ended in the extension .php, other extensions would not be returned. The array returned by get_required_files was an associative array and only listed files included by require and require_once. See also: require, require_once, include, include_once, and get_included_files. getrusage Gets the current resource usages Description arraygetrusage intwho This is an interface to getrusage(2). It returns an associative array containing the data returned from the system call. If who is 1, getrusage will be called with RUSAGE_CHILDREN. All entries are accessible by using their documented field names. Getrusage Example See your system's man page on getrusage(2) for more details. ini_alter Changes the value of a configuration option Description stringini_alter stringvarname stringnewvalue Changes the value of a configuration option, returns &false; on failure, and the previous value of the configuration option on success. This is an alias of ini_set See also ini_get, ini_get_all, ini_restore, and ini_set ini_get Gets the value of a configuration option Description stringini_get stringvarname Returns the value of the configuration option on success, an empty string on failure. See also get_cfg_var, ini_get_all, ini_alter, ini_restore, and ini_set ini_get_all Gets all configuration options Description arrayini_get_all stringextension Returns all the registered configuration options as an associative array. If optional extension parameter is set, returns only options specific for that extension. See also: ini_alter, ini_restore, ini_get, and ini_set ini_restore Restores the value of a configuration option Description stringini_restore stringvarname Restores a given configuration option to its original value. See also: ini_alter, ini_get, ini_get_all, and ini_set ini_set Sets the value of a configuration option Description stringini_set stringvarname stringnewvalue Sets the value of the given configuration option. Returns the old value on success, &false; on failure. The configuration option will keep this new value during the script's execution, and will be restored at the script's ending. Not all the available options can be changed using ini_set. Below is a table with a list of all PHP options (as of PHP 4.0.5-dev), indicating which ones can be changed/set and at what level. <link linkend="configuration">Configuration</link> options Name Default Changeable define_syslog_variables "0" PHP_INI_ALL highlight.bg HL_BG_COLOR PHP_INI_ALL highlight.comment HL_COMMENT_COLOR PHP_INI_ALL highlight.default HL_DEFAULT_COLOR PHP_INI_ALL highlight.html HL_HTML_COLOR PHP_INI_ALL highlight.keyword HL_KEYWORD_COLOR PHP_INI_ALL highlight.string HL_STRING_COLOR PHP_INI_ALL allow_call_time_pass_reference "1" PHP_INI_SYSTEM|PHP_INI_PERDIR asp_tags "0" PHP_INI_SYSTEM|PHP_INI_PERDIR display_errors "1" PHP_INI_ALL display_startup_errors "0" PHP_INI_ALL enable_dl "1" PHP_INI_SYSTEM error_append_string &null; PHP_INI_ALL error_prepend_string &null; PHP_INI_ALL expose_php "1" PHP_INI_SYSTEM html_errors "1" PHP_INI_SYSTEM ignore_user_abort "0" PHP_INI_ALL implicit_flush "0" PHP_INI_PERDIR|PHP_INI_SYSTEM log_errors "0" PHP_INI_ALL magic_quotes_gpc "1" PHP_INI_PERDIR|PHP_INI_SYSTEM magic_quotes_runtime "0" PHP_INI_ALL magic_quotes_sybase "0" PHP_INI_PERDIR|PHP_INI_SYSTEM output_buffering "0" PHP_INI_PERDIR|PHP_INI_SYSTEM output_handler &null; PHP_INI_PERDIR|PHP_INI_SYSTEM register_argc_argv "1" PHP_INI_ALL register_globals "1" PHP_INI_PERDIR|PHP_INI_SYSTEM safe_mode "0" PHP_INI_SYSTEM short_open_tag "1" PHP_INI_SYSTEM|PHP_INI_PERDIR sql.safe_mode "0" PHP_INI_SYSTEM track_errors "0" PHP_INI_ALL y2k_compliance "0" PHP_INI_ALL arg_separator "&" PHP_INI_ALL auto_append_file &null; PHP_INI_ALL auto_prepend_file &null; PHP_INI_ALL doc_root &null; PHP_INI_SYSTEM default_charset SAPI_DEFAULT_CHARSET PHP_INI_ALL default_mimetype SAPI_DEFAULT_MIMETYPE PHP_INI_ALL error_log &null; PHP_INI_ALL extension_dir PHP_EXTENSION_DIR PHP_INI_SYSTEM gpc_order "GPC" PHP_INI_ALL include_path PHP_INCLUDE_PATH PHP_INI_ALL max_execution_time "30" PHP_INI_ALL open_basedir &null; PHP_INI_SYSTEM safe_mode_exec_dir "1" PHP_INI_SYSTEM upload_max_filesize "2M" PHP_INI_ALL file_uploads "1" PHP_INI_ALL post_max_size "8M" PHP_INI_SYSTEM upload_tmp_dir &null; PHP_INI_SYSTEM user_dir &null; PHP_INI_SYSTEM variables_order &null; PHP_INI_ALL SMTP "localhost" PHP_INI_ALL browscap &null; PHP_INI_SYSTEM error_reporting &null; PHP_INI_ALL memory_limit "8M" PHP_INI_ALL precision "14" PHP_INI_ALL sendmail_from &null; PHP_INI_ALL sendmail_path DEFAULT_SENDMAIL_PATH PHP_INI_SYSTEM disable_functions "" PHP_INI_SYSTEM allow_url_fopen "1" PHP_INI_ALL
Definition of PHP_INI_* constants Constant Value Meaning PHP_INI_USER 1 Entry can be set in user scripts PHP_INI_PERDIR 2 Entry can be set in .htaccess PHP_INI_SYSTEM 4 Entry can be set in php.ini or httpd.conf PHP_INI_ALL 7 Entry can be set anywhere
See also: ini_alter, ini_get, and ini_restore
phpcredits Prints out the credits for PHP Description voidphpcredits intflag This function prints out the credits listing the PHP developers, modules, etc. It generates the appropriate HTML codes to insert the information in a page. A parameter indicating what will be printed (a pre-defined constant flag, see table below) needs to be passed. For example to print the general credits, you will use somewhere in your code: And if you want to print the core developers and the documentation group, in a page of its own, you will use: ]]> And if you feel like embedding all the credits in your page, then code like the one below will do it: My credits page ]]> Pre-defined <function>phpcredits</function> flags name description CREDITS_ALL All the credits, equivalent to using: CREDITS_DOCS + CREDITS_GENERAL + CREDITS_GROUP + CREDITS_MODULES + CREDITS_FULLPAGE. It generates a complete stand-alone HTML page with the appropriate tags. CREDITS_DOCS The credits for the documentation team CREDITS_FULLPAGE Usually used in combination with the other flags. Indicates that the a complete stand-alone HTML page needs to be printed including the information indicated by the other flags. CREDITS_GENERAL General credits: Language design and concept, PHP 4.0 authors and SAPI module. CREDITS_GROUP A list of the core developers CREDITS_MODULES A list of the extension modules for PHP, and their authors CREDITS_SAPI A list of the server API modules for PHP, and their authors
See also: phpinfo, phpversion, and php_logo_guid.
phpinfo Outputs lots of PHP information Description intphpinfo intwhat Outputs a large amount of information about the current state of PHP. This includes information about PHP compilation options and extensions, the PHP version, server information and environment (if compiled as a module), the PHP environment, OS version information, paths, master and local values of configuration options, HTTP headers, and the PHP License. Because every system is setup differently, phpinfo is commonly used to check configuration settings and for available predefined variables on a given system. Also, phpinfo is a valuable debugging tool as it contains all EGPCS (Environment, GET, POST, Cookie, Server) data. The output may be customized by passing one or more of the following constants bitwise values summed together in the optional what parameter. One can also combine the respective constants or bitwise values together with the or operator. <function>phpinfo</function> options Name (constant) Value Description INFO_GENERAL 1 The configuration line, php.ini location, build date, Web Server, System and more. INFO_CREDITS 2 PHP 4 Credits. See also phpcredits. INFO_CONFIGURATION 4 Current Local and Master values for php directives. See also ini_get. INFO_MODULES 8 Loaded modules and there respective settings. INFO_ENVIRONMENT 16 Environment Variable information that's also available in $_ENV. INFO_VARIABLES 32 Shows all predefined variables from EGPCS (Environment, GET, POST, Cookie, Server). INFO_LICENSE 64 PHP License information. See also the license faq. INFO_ALL -1 Shows all of the above. This is the default value.
<function>phpinfo</function> examples ]]> Parts of the information displayed are disabled when the expose_php configuration setting is set to off. This includes the PHP and Zend logos, and the credits. See also: phpversion, phpcredits, php_logo_guid, ini_get, ini_set, and the section on Predefined Variables.
phpversion Gets the current PHP version Description stringphpversion Returns a string containing the version of the currently running PHP parser. This information is also available in the predefined constant PHP_VERSION. <function>phpversion</function> Example ]]> See also version_compare, phpinfo, phpcredits, php_logo_guid, and zend_version. php_logo_guid Gets the logo guid Description stringphp_logo_guid This functionality was added in PHP 4.0.0. See also: phpinfo, phpversion, and phpcredits. php_sapi_name Returns the type of interface between web server and PHP Description stringphp_sapi_name php_sapi_name returns a lowercase string which describes the type of interface between web server and PHP (Server API, SAPI). In CGI PHP, this string is "cgi", in mod_php for Apache, this string is "apache" and so on. <function>php_sapi_name</function> Example php_uname Returns information about the operating system PHP was built on Description stringphp_uname php_uname returns a string with a description of the operating system PHP is built on. <function>php_uname</function> Example putenv Sets the value of an environment variable Description voidputenv stringsetting Adds setting to the server environment. The environment variable will only exist for the duration of the current request. At the end of the request the environment is restored to its original state. Setting certain environment variables may be a potential security breach. The safe_mode_allowed_env_vars directive contains a comma-delimited list of prefixes. In Safe Mode, the user may only alter environment variables whose names begin with the prefixes supplied by this directive. By default, users will only be able to set environment variables that begin with PHP_ (e.g. PHP_FOO=BAR). Note: if this directive is empty, PHP will let the user modify ANY environment variable! The safe_mode_protected_env_vars directive contains a comma-delimited list of environment variables, that the end user won't be able to change using putenv. These variables will be protected even if safe_mode_allowed_env_vars is set to allow to change them. These directives have only effect when safe-mode itself is enabled! Setting an Environment Variable See also getenv. set_magic_quotes_runtime Sets the current active configuration setting of magic_quotes_runtime Description longset_magic_quotes_runtime intnew_setting Set the current active configuration setting of magic_quotes_runtime (0 for off, 1 for on). See also: get_magic_quotes_gpc and get_magic_quotes_runtime. set_time_limit Limits the maximum execution time Description voidset_time_limit intseconds Set the number of seconds a script is allowed to run. If this is reached, the script returns a fatal error. The default limit is 30 seconds or, if it exists, the max_execution_time value defined in the configuration file. If seconds is set to zero, no time limit is imposed. When called, set_time_limit restarts the timeout counter from zero. In other words, if the timeout is the default 30 seconds, and 25 seconds into script execution a call such as set_time_limit(20) is made, the script will run for a total of 45 seconds before timing out. set_time_limit has no effect when PHP is running in safe mode. There is no workaround other than turning off safe mode or changing the time limit in the configuration file. The set_time_limit function and the configuration directive max_execution_time only affect the execution time of the script itself. Any time spent on activity that happens outside the execution of the script such as system calls using system, the sleep function, database queries, etc. is not included when determining the maximum time that the script has been running. version_compare Compares two "PHP-standardized" version number strings Description intversion_compare stringversion1 stringversion2 string operator version_compare compares two "PHP-standardized" version number strings. This is useful if you would like to write programs working only on some versions of PHP. version_compare returns -1 if the first version is lower than the second, 0 if they are equal, and +1 if the second is lower. If you specify the third optional operator argument, you can test for a particular relationship. The possible operators are: <, lt, <=, le, >, gt, >=, ge, ==, =, eq, !=, <>, ne respectively. Using this argument, the function will return 1 if the relationship is the one specified by the operator, 0 otherwise. <function>version_compare</function> Example zend_logo_guid Gets the zend guid Description stringzend_logo_guid This functionality was added in PHP 4.0.0. zend_version Gets the version of the current Zend engine Description stringzend_version Returns a string containing the version of the currently running PHP parser. <function>zend_version</function> Example See also phpinfo, phpcredits, php_logo_guid, and phpversion.