In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article will explain in detail how to use PHP-based options and information functions. The editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.
Bool assert (mixed $assertion [, string $description])-checks whether an assertion is FALSE
The code is as follows:
Assert_options (ASSERT_ACTIVE, true); / / the assert () function is allowed
Assert_options (ASSERT_WARNING, false); / / No warning message is output when assert fails
Assert_options (ASSERT_BAIL, true); / / terminate code execution when assert fails
Assert_options (ASSERT_CALLBACK, 'getMsg'); / / assert terminates code execution after a failure.
Echo 'start:'
Assert ('mysql_query (")')
Echo 'test succeeded!'
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 () assertion, ini configures assert.active, default is 1
ASSERT_WARNING: whether to generate a PHP warning for each failed assertion. Ini configure assert.warning. Default is 1.
ASSERT_BAIL: whether to abort execution if the assertion fails. Ini configures assert.bail. The default is 0.
ASSERT_QUIET_EVAL: whether to disable error_reporting,ini configuration assert.quiet_eval when evaluating an assertion expression. The default is 0
ASSERT_CALLBACK: call the callback function when the assertion fails, and configure assert.callback with ini
The code is as follows:
Assert_options (ASSERT_ACTIVE, true); / / the assert () function is allowed
Assert_options (ASSERT_WARNING, false); / / No warning message is output when assert fails
Assert_options (ASSERT_BAIL, true); / / terminate code execution when assert fails
Assert_options (ASSERT_CALLBACK, 'getMsg'); / / assert terminates code execution after a failure.
Echo 'start:'
Assert (is_int 1.2); / / the test result is fales
Echo 'test succeeded!'
Function getMsg () {
Echo 'error!'
}
Bool dl (string $library)-gets the value of the PHP configuration option to 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 ()-force collection of all existing garbage cycles
Void gc_disable (void)-deactivate the circular reference collector
Void gc_enable (void)-activates the circular reference collector
Bool gc_enabled (void)-returns the status of the circular 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)-gets the owner name of the current PHP script
Array get_defined_constants ([bool $categorize = false])-returns an associative array of all constants
Array get_extension_funcs (string $module_name)-returns an array of module function names
The code is as follows:
Print_r (get_extension_funcs ("xml"))
String get_include_path (void)-gets the current include_path configuration option
Array get_included_files (void)-returns the array of the include and require filename
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 all array that are compiled and loaded with module names
Bool get_magic_quotes_gpc (void)-gets the configuration option settings for 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)-gets the value of an environment variable
The code is as follows:
$ip = getenv ('REMOTE_ADDR')
Int getlastmod (void)-gets the time when the page was last modified
Int getmygid (void)-gets the GID of the owner of the current PHP script
Int getmyinode (void)-gets the Inode (inode) of the current script
Int getmypid (void)-gets the ID of the PHP process
Int getmyuid (void)-gets the UID of the owner of the PHP script
Array getopt (string $options [, array $longopts])-get options from the command line argument list
Array getrusage ([int $who = 0])-gets 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)-gets the value of a configuration option
Void ini_restore (string $varname)-restore the default value of the configuration option
String ini_set (string $varname, string $newvalue)-sets the value for a configuration option
Main-Virtual main () int memory_get_peak_usage ([bool $real_usage = false])-returns the peak int memory_get_usage allocated to PHP memory ([bool $real_usage = false])-returns the amount of memory allocated to PHP
String php_ini_loaded_file (void)-gets the path to the loaded php.ini file
String php_ini_scanned_files (void)-returns a list of .ini files parsed from an extra ini directory
String php_sapi_name (void)-returns the type of interface between the web server and PHP
String php_uname ([string $mode = "a"])-returns information about the system running PHP
'asides: this is the default all.
'skeeper: operating system name
'nails: hostname. For example: localhost.example.com.
'ringing: version name, for example: 5.1.2-RELEASE.
'vested: version information. There are big differences between operating systems.
'masking: machine type. For example: i386.
Bool phpcredits ([int $flag = CREDITS_ALL])-print a list of PHP contributors
CREDITS_ALL: all of them
CREDITS_DOCS: documentation group contribution list
CREDITS_FULLPAGE: often used to combine with other flags. Indicates that you need to print a separate HTML page that contains information represented by other flags.
CREDITS_GENERAL: universal list: language Design and philosophy, PHP authors, and SAPI Modules
CREDITS_GROUP: core developer list
CREDITS_MODULES: PHP extension module and author
CREDITS_SAPI: PHP's server API module and author
The copy code is as follows:
Phpcredits (CREDITS_GROUP | CREDITS_DOCS | CREDITS_FULLPAGE)
Bool phpinfo ([int $what = INFO_ALL])-outputs information about the PHP configuration
String phpversion ([string $extension])-get the current PHP version
Bool putenv (string $setting)-sets 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)-sets include_path configuration options
Void set_time_limit (int $seconds)-sets the maximum execution time of the script, starting with itself. 0 means unlimited time.
String sys_get_temp_dir (void)-returns the directory used for temporary files
Mixed version_compare (string $version1, string $version2 [, string $operator])-compare two PHP normalized versions of 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)-returns the unique identifier of the current thread
String zend_version (void)-gets the version of the current Zend engine
This is the end of this article on "how to use PHP-based options and information functions". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.