_php example based on the use of PHP options and information functions

Source: Internet
Author: User
Tags assert mixed number strings php server php script sqlite zend
bool assert(Mixed $assertion [, String $description])-Checks whether an assertion is FALSE
Copy Code code as follows:

Assert_options (assert_active, true);//allow use of the ASSERT () function
Assert_options (assert_warning, false);//Do not export warning message when ASSERT fails
Assert_options (Assert_bail, True), terminating code execution after//assert failure
Assert_options (Assert_callback, ' getmsg '), terminating code execution after//assert failure.

Echo ' begins:<br/> ';
Assert (' mysql_query (") ');
echo ' Test success! ';

function getmsg () {
Echo ' went wrong! ';
}

Mixed Assert_options(int $what [, mixed $value])-Sets the various control options for assert (), or queries the current settings
Assert_active: Assert () assertion is enabled, INI configuration assert.active, default value 1
Assert_warning: Whether to generate a PHP warning for each failed assertion, INI configuration assert.warning, default 1
Assert_bail: Abort execution if assertion fails, INI configuration assert.bail, default value 0
Assert_quiet_eval: Whether to disable Error_reporting,ini configuration assert.quiet_eval when asserting expression evaluation, default value 0
Assert_callback: Call callback function when assertion fails, INI configuration assert.callback
Copy Code code as follows:

Assert_options (assert_active, true);//allow use of the ASSERT () function
Assert_options (assert_warning, false);//Do not export warning message when ASSERT fails
Assert_options (Assert_bail, True), terminating code execution after//assert failure
Assert_options (Assert_callback, ' getmsg '), terminating code execution after//assert failure.

Echo ' begins:<br/> ';
ASSERT (Is_int (1.2));//The test result is Fales
echo ' Test success! ';

function getmsg () {
Echo ' went wrong! ';
}

BOOL DL (string $library)-Gets the value of the PHP configuration option load the specified PHP extension
Copy Code code as follows:

if (!extension_loaded (' SQLite ')) {//test whether the specified extension is active
$prefix = (Php_shlib_suffix = = ' dll ')? ' Php_ ': ';
DL ($prefix. ' SQLite. ' Php_shlib_suffix);
}

int Gc_collect_cycles ()-forces collection of all existing garbage cycles
void gc_disable (void)-Deactivate circular reference collector
void gc_enable (void)-Activate circular reference collector
BOOL Gc_enabled (void)-Returns the state of a 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 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 code 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 an array of include and require file names
Copy Code code 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 an array of all compiled and loaded 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 active status of the current magic_quotes_runtime configuration option
String getenv (String $varname)-Gets the value of an environment variable
Copy Code code as follows:

$ip = getenv (' remote_addr ');

int getlastmod (void)-Gets the time when the page was last modified
int Getmygid (void)-Gets the GID for the current PHP script owner
int Getmyinode (void)-Gets the index node (inode) of the current script
int getmypid (void)-Gets the ID of the PHP process
int Getmyuid (void)-Gets the UID of the PHP script owner
Array getopt (string $options [, array $longopts])-Get options from the command line argument list
Array getrusage ([int $who = 0])-Get current Resource usage
Array Ini_get_all ([string $extension [, bool $details = true]]-Get all configuration options
Copy Code code 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)-Default value for restore configuration options
String Ini_set (String $varname, String $newvalue)-set 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 $r Eal_usage = false])-Returns the amount of memory allocated to PHP
String Php_ini_loaded_file (void)-Gets the path of the loaded php.ini file
String Php_ini_scanned_files (void)-Returns a list of. ini files parsed from the additional 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
' 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 is a big difference between the operating system.
' m ': machine type. For example: i386.
BOOL Phpcredits ([int $flag = Credits_all])-Print list of PHP contributors
Credits_all: All
Credits_docs: Document Group Contribution list
Credits_fullpage: Often used in combination with other flags. Indicates that you need to print a separate HTML page that contains information about other flags.
Credits_general: Universal list: Language design and ideas, PHP authors, and SAPI modules
Credits_group: List of core developers
credits_modules:php Extension Module and author
credits_sapi:php Server API module and author
Copy Code code as follows:

Phpcredits (Credits_group | Credits_docs | Credits_fullpage);

BOOL Phpinfo ([int $what = Info_all])-Output information about the PHP configuration
String Phpversion ([string $extension])-Get current version of PHP
BOOL Putenv (String $setting)-Set the value of an environment variable
void Restore_include_path (void)-value of the Restore 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 for the script, starting with the timer itself, 0 indicates unlimited
String Sys_get_temp_dir (void)-Returns the directory used for temporary files
Mixed Version_compare (String $version 1, String $version 2 [, String $operator])-Compare two PHP normalized version number strings
Copy Code code 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 a unique identifier for the current thread
String zend_version (void)-Gets the version of the current Zend engine

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.