search
HomeBackend DevelopmentPHP TutorialDetailed 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

Jul 21, 2016 pm 03:11 PM
assertphpstringanduseinformationfunctionbased onofDetailed explanationOptions

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
PHP and Python: Different Paradigms ExplainedPHP and Python: Different Paradigms ExplainedApr 18, 2025 am 12:26 AM

PHP is mainly procedural programming, but also supports object-oriented programming (OOP); Python supports a variety of paradigms, including OOP, functional and procedural programming. PHP is suitable for web development, and Python is suitable for a variety of applications such as data analysis and machine learning.

PHP and Python: A Deep Dive into Their HistoryPHP and Python: A Deep Dive into Their HistoryApr 18, 2025 am 12:25 AM

PHP originated in 1994 and was developed by RasmusLerdorf. It was originally used to track website visitors and gradually evolved into a server-side scripting language and was widely used in web development. Python was developed by Guidovan Rossum in the late 1980s and was first released in 1991. It emphasizes code readability and simplicity, and is suitable for scientific computing, data analysis and other fields.

Choosing Between PHP and Python: A GuideChoosing Between PHP and Python: A GuideApr 18, 2025 am 12:24 AM

PHP is suitable for web development and rapid prototyping, and Python is suitable for data science and machine learning. 1.PHP is used for dynamic web development, with simple syntax and suitable for rapid development. 2. Python has concise syntax, is suitable for multiple fields, and has a strong library ecosystem.

PHP and Frameworks: Modernizing the LanguagePHP and Frameworks: Modernizing the LanguageApr 18, 2025 am 12:14 AM

PHP remains important in the modernization process because it supports a large number of websites and applications and adapts to development needs through frameworks. 1.PHP7 improves performance and introduces new features. 2. Modern frameworks such as Laravel, Symfony and CodeIgniter simplify development and improve code quality. 3. Performance optimization and best practices further improve application efficiency.

PHP's Impact: Web Development and BeyondPHP's Impact: Web Development and BeyondApr 18, 2025 am 12:10 AM

PHPhassignificantlyimpactedwebdevelopmentandextendsbeyondit.1)ItpowersmajorplatformslikeWordPressandexcelsindatabaseinteractions.2)PHP'sadaptabilityallowsittoscaleforlargeapplicationsusingframeworkslikeLaravel.3)Beyondweb,PHPisusedincommand-linescrip

How does PHP type hinting work, including scalar types, return types, union types, and nullable types?How does PHP type hinting work, including scalar types, return types, union types, and nullable types?Apr 17, 2025 am 12:25 AM

PHP type prompts to improve code quality and readability. 1) Scalar type tips: Since PHP7.0, basic data types are allowed to be specified in function parameters, such as int, float, etc. 2) Return type prompt: Ensure the consistency of the function return value type. 3) Union type prompt: Since PHP8.0, multiple types are allowed to be specified in function parameters or return values. 4) Nullable type prompt: Allows to include null values ​​and handle functions that may return null values.

How does PHP handle object cloning (clone keyword) and the __clone magic method?How does PHP handle object cloning (clone keyword) and the __clone magic method?Apr 17, 2025 am 12:24 AM

In PHP, use the clone keyword to create a copy of the object and customize the cloning behavior through the \_\_clone magic method. 1. Use the clone keyword to make a shallow copy, cloning the object's properties but not the object's properties. 2. The \_\_clone method can deeply copy nested objects to avoid shallow copying problems. 3. Pay attention to avoid circular references and performance problems in cloning, and optimize cloning operations to improve efficiency.

PHP vs. Python: Use Cases and ApplicationsPHP vs. Python: Use Cases and ApplicationsApr 17, 2025 am 12:23 AM

PHP is suitable for web development and content management systems, and Python is suitable for data science, machine learning and automation scripts. 1.PHP performs well in building fast and scalable websites and applications and is commonly used in CMS such as WordPress. 2. Python has performed outstandingly in the fields of data science and machine learning, with rich libraries such as NumPy and TensorFlow.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
Will R.E.P.O. Have Crossplay?
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools