Home >Backend Development >PHP Tutorial >Detailed explanation based on the use of PHP options and information functions_PHP tutorial

Detailed explanation based on the use of PHP options and information functions_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 15:11:03848browse

bool assert ( mixed $assertion [, string $description ] ) — Checks whether an assertion is FALSE

Copy code The code is as follows:

assert_options(ASSERT_ACTIVE, true);//Allows the use of the assert() function
assert_options(ASSERT_WARNING, false);//Does not output a warning message when 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 'An error occurred! ';
}

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 configuration assert.active, default value 1
ASSERT_WARNING: Whether to generate a PHP warning for each failed assertion, ini configuration assert.warning, default value 1
ASSERT_BAIL : Whether to abort execution when assertion fails, ini configuration assert.bail, default value 0
ASSERT_QUIET_EVAL: Whether to disable error_reporting when assertion expression is evaluated, ini configuration assert.quiet_eval, default value 0
ASSERT_CALLBACK: Assertion failed The callback function is called when the ini configuration assert.callback
Copy code The code is as follows:

assert_options(ASSERT_ACTIVE, true);/ /Allow the use of the assert() function
assert_options(ASSERT_WARNING, false);//Do not output warning information when 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 false
echo 'Test successful! ';

function getMsg(){
echo 'An error occurred! ';
}

bool dl( string $library ) — Get the value of PHP configuration option and load the specified PHP extension
Copy code 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 Cycle period
void gc_disable (void) — Disable the circular reference collector
void gc_enable (void) — Activate the circular reference collector
bool gc_enabled (void) — Return the status of the circular reference counter
string get_cfg_var ( string $option ) — Get the value of the PHP configuration option Get the value of the PHP configuration option
string get_current_user ( void ) — Get the current PHP script owner name
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
Copy code 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) — Return the included and require Array of file names
Copy code 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 "$filenamen";
}

array get_loaded_extensions ([ bool $zend_extensions = false ] ) — Returns an array of all compiled and loaded module names
bool get_magic_quotes_gpc ( void ) — Get the current magic_quotes_gpc configuration option settings
bool get_magic_quotes_runtime ( void ) — Get the activation status of the current magic_quotes_runtime configuration option
string getenv ( string $varname ) — Get the value of an environment variable
Copy code The code is as follows:

$ip = getenv('REMOTE_ADDR');

int getlastmod (void)—Get the last modified 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 ID of the PHP process
int getmyuid ( void ) — Get the UID of the PHP script owner
array getopt ( string $options [, array $longopts ] ) — From the command line Get options in the 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
Copy code The code is as follows:

print_r(ini_get_all("pcre"));
print_r(ini_get_all() );

string ini_get ( string $varname ) — Get the value of a configuration option
void ini_restore ( string $varname ) — Restore the default value of a 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 ([ 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 the .ini file parsed from the extra ini directory List
string php_sapi_name (void) — Returns the interface type between the web server and PHP
string php_uname ([ string $mode = "a" ] ) — Returns information about the system running PHP
'a ': This is the default 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 big differences between operating systems.
'm': machine type. For example: i386.
bool phpcredits ([ int $flag = CREDITS_ALL ] ) — Print PHP contributor list
CREDITS_ALL : All
CREDITS_DOCS : Document group contribution list
CREDITS_FULLPAGE : Often used in combination with other flags. Indicates the need to print a separate HTML page containing information represented by other flags.
CREDITS_GENERAL: General list: language design and philosophy, PHP authors and SAPI modules
CREDITS_GROUP: Core developer list
CREDITS_MODULES: PHP extension modules and authors
CREDITS_SAPI: PHP server API modules and authors
Copy code 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 environment variables Value
void restore_include_path (void) — Restore the value of the include_path configuration option
string set_include_path ( string $new_include_path ) — Set the include_path configuration option
void set_time_limit ( int $seconds ) — Set the maximum execution time of the script from which Start timing by itself, 0 means no time limit
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 normalizations The version number string
Copy code 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 identification of the current thread Symbol
string zend_version (void) — Get the current Zend engine version

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/326992.htmlTechArticlebool assert ( mixed $assertion [, string $description ] ) — Check whether an assertion is FALSE. Copy the code. The code is as follows : assert_options(ASSERT_ACTIVE, true);//Allow the use of assert() function...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn