PHP-based options and information functions

Source: Internet
Author: User
This article provides a detailed analysis of the use of PHP options and information functions. For more information, see bool. Assert(Mixed $ assertion [, string $ description])-check whether an asserted is FALSE

The Code is as follows:


Assert_options (ASSERT_ACTIVE, true); // allows the use of the assert () function
Assert_options (ASSERT_WARNING, false); // no warning message is output when the assert fails.
Assert_options (ASSERT_BAIL, true); // terminate code execution after assert fails.
Assert_options (ASSERT_CALLBACK, 'getmsg '); // terminate code execution after assert fails.

Echo 'start:
';
Assert ('mysql _ query ("")');
Echo 'test successful! ';

Function getMsg (){
Echo 'error! ';
}


Mixed assert_options(Int $ what [, mixed $ value])-set various control options for assert () or query the current settings
ASSERT_ACTIVE: whether to enable assert () Assertions. ini configures assert. active. The default value is 1.
ASSERT_WARNING: whether to generate a PHP warning for each failed ASSERT_WARNING. The default value is 1 when assert. warning is configured in ini.
ASSERT_BAIL: Indicates whether to stop execution when the ASSERT_BAIL assertion fails. ini configures assert. bail. The default value is 0.
ASSERT_QUIET_EVAL: whether to disable error_reporting when the asserted expression is evaluated. ini configures assert. quiet_eval. The default value is 0.
ASSERT_CALLBACK: the callback function is called when the assertions fail. ini configures assert. callback.

The Code is as follows:


Assert_options (ASSERT_ACTIVE, true); // allows the use of the assert () function
Assert_options (ASSERT_WARNING, false); // no warning message is output when the assert fails.
Assert_options (ASSERT_BAIL, true); // terminate code execution after assert fails.
Assert_options (ASSERT_CALLBACK, 'getmsg '); // terminate code execution after assert fails.

Echo 'start:
';
Assert (is_int (1.2); // The detection result is fales.
Echo 'test successful! ';

Function getMsg (){
Echo 'error! ';
}


Bool dl (string $ library)-Get the PHP configuration option value and load the specified PHP Extension

The Code is as follows:


If (! Extension_loaded ('sqlite ') {// test whether the specified extension has been activated
$ Prefix = (PHP_SHLIB_SUFFIX = 'dll ')? 'Php _':'';
Dl ($ prefix. 'sqlite. '. PHP_SHLIB_SUFFIX );
}


Int gc_collect_cycles ()-Forces collection of all existing garbage cycle
Void gc_disable (void)-Disable cyclic reference collector
Void gc_enable (void)-activate the cyclic reference collector
Bool gc_enabled (void)-return the status of the cyclic Reference Counter
String get_cfg_var (string $ option)-Get the value of the PHP configuration option to get the value of the PHP configuration option
String get_current_user (void)-Get the name of the current PHP script owner
Array get_defined_constants ([bool $ categorize = false])-returns the joined array of all constants.
Array get_extension_funcs (string $ module_name)-returns the array of the module function name

The Code is as follows:


Print_r (get_extension_funcs ("xml "));


String get_include_path (void)-Get the current include_path configuration option
Array get_included_files (void)-returns the array with the names of include and require files

The Code is as follows:


Include 'test1. php ';
Include_once 'test2. php ';
Require 'test3. php ';
Require_once 'test4. php ';

$ Included_files = get_included_files ();

Foreach ($ included_files as $ filename ){
Echo "$ filename \ n ";
}


Array get_loaded_extensions ([bool $ zend_extensions = false])-returns the array of all compiled and loaded module names.
Bool get_magic_quotes_gpc (void)-Get the configuration option settings of the current magic_quotes_gpc
Bool get_magic_quotes_runtime (void)-gets the activation status of the current magic_quotes_runtime configuration option
String getenv (string $ varname)-obtains the value of an environment variable.

The Code is as follows:


$ Ip = getenv ('remote _ ADDR ');


Int getlastmod (void)-Get the last modification time of the page
Int getmygid (void)-Get the GID of the current PHP script owner
Int getmyinode (void)-Get the index node (inode) of the current script)
Int getmypid (void)-Get the PHP process ID
Int getmyuid (void)-Get the UID of the PHP script owner
Array getopt (string $ options [, array $ longopts])-obtain the option from the command line parameter list
Array getrusage ([int $ who = 0])-Get the current resource usage
Array ini_get_all ([string $ extension [, bool $ details = true])-Get all configuration options

The Code is as follows:


Print_r (ini_get_all ("pcre "));
Print_r (ini_get_all ());


String ini_get (string $ varname)-obtains the value of a configuration option.
Void ini_restore (string $ varname)-default value of the restore configuration option
String ini_set (string $ varname, string $ newvalue)-set a value for a configuration option
Main-virtual main () int memory_get_peak_usage ([bool $ real_usage = false])-return the peak int memory_get_usage ([bool $ real_usage = false]) allocated to the PHP memory. -The amount of memory allocated to PHP is returned.
String php_ini_loaded_file (void)-obtain the path of the loaded php. ini file
String php_ini_scanned_files (void)-returns the list of. ini files parsed from the extra ini directory.
String php_sapi_name (void)-return the interface type between the web server and PHP.
String php_uname ([string $ mode = "a"])-returns information about the system running PHP.
'A': The default value is all.
'S ': Operating System name
'N': Host Name. For example, localhost.example.com.
'R': version name, for example, 5.1.2-RELEASE.
'V': version information. There are major differences between operating systems.
'M': machine type. For example, i386.
Bool phpcredits ([int $ flag = CREDITS_ALL])-print the PHP contributor list
CREDITS_ALL: All
CREDITS_DOCS: Document group contribution list
CREDITS_FULLPAGE: used in combination with other labels. To print an independent HTML page containing other tags.
CREDITS_GENERAL: General List: language design and philosophy, PHP author, and SAPI module
CREDITS_GROUP: list of core developers
CREDITS_MODULES: PHP extension module and author
CREDITS_SAPI: PHP server API module and author

The Code is as follows:


Phpcredits (CREDITS_GROUP | CREDITS_DOCS | CREDITS_FULLPAGE );


Bool phpinfo ([int $ what = INFO_ALL])-output information about PHP configuration
String phpversion ([string $ extension])-Get the current PHP version
Bool putenv (string $ setting)-set the value of the environment variable
Void restore_include_path (void)-restore the value of the include_path configuration option
String set_include_path (string $ new_include_path)-set include_path configuration options
Void set_time_limit (int $ seconds)-sets the maximum execution time of the script, starting from its own time. 0 indicates the time limit.
String sys_get_temp_dir (void)-return the directory used for temporary files
Mixed version_compare (string $ version1, string $ version2 [, string $ operator])-compare two standardized PHP version numeric strings

The Code is as follows:


If (version_compare (PHP_VERSION, '5. 3.0 ')> = 0 ){
Echo 'my PHP version is very high: '. PHP_VERSION. "\ n ";
}


Int zend_thread_id (void)-return the unique identifier of the current thread
String zend_version (void)-Get the current Zend Engine Version

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.