PHP option and related information function library

Source: Internet
Author: User

Error_log: sends an error message.
Error_reporting: the level of returned error information.
Getenv: Get the environment variable of the system
Get_cmd_var: Get the PHP configuration option value.
Get_current_user: get the name of the PHP itinerary owner.
Get_magic_quotes_gpc: obtains the value of the PHP environment variable magic_quotes_gpc.
Get_magic_quotes_runtime: gets the value of the PHP environment variable magic_quotes_runtime.
Getlastmod: returns the last modification time of the webpage.
Getmyinode: return the inode value of the webpage.
Getmypid: return the PHP travel code.
Getmyuid: return the PHP user code.
Getrusage: returns the system resource usage.
Phpinfo: returns all related PHP information.
Phpversion: returns the PHP version information.
Putenv: configure system environment variables.
Set_magic_quotes_runtime: configure the value of magic_quotes_runtime.
Set_time_limit: Set the longest execution time for this page.

Int error_log
Syntax: int error_log (string message, int message_type, string [destination], string [extra_headers]);
Return Value: integer
Function types: PHP system functions
Description: This function sends an error message to the Web server's Error log File, TCP Port, or to the specified file. The first parameter message is the error message to be sent. The second parameter message_type is an integer. 0 indicates the log sent to the Operating System (events are recorded in syslogs and Windows NT in UNIX). 1. Use the Mail () function of PHP, send information to an e-mail address. The fourth parameter extra_headers is also used. 2. Send the error message to the TCP Port. The third parameter destination indicates the destination IP address and Port; 3. Save the information to the file destination.
Example
In this example, problems occur when logging on to the Oracle database.
<? Php
If (! Ora_Logon ($ username, $ password )){
Error_log ("Oracle Database unavailable! ", 0 );
}
If (! ($ Foo = allocate_new_foo ()){
Error_log ("It's a big headache! ", 1," webmaster@www.mydomain.com.tw ");
}
Error_log ("screwed up! ", 2," 127.0.0.1: 7000 ");
Error_log ("screwed up! ", 2," loghost ");
Error_log ("screwed up! ", 3,"/var/tmp/my-errors.log ");
?>

Error_reporting
Configure the error message return level.
Syntax: int error_reporting (int [level]);
Return Value: integer
Function types: PHP system functions
Description: This function is used to configure the error message return level. The level parameter is an integer bitmask. See the following table.
Mask Value
1 E_ERROR
2 E_WARNING
4 E_PARSE
8 E_NOTICE
16 E_CORE_ERROR
32 E_CORE_WARNING



E_NOTICE indicates that it is not recorded in general cases and used only when the program has an error, for example, an attempt to access a non-existent variable or call the stat () function to view a non-existent file.
E_WARNING is usually displayed, but the execution of the program is not interrupted. This is effective for debugging. For example, call ereg () with a problematic regular expression ().
E_ERROR is usually displayed and the program execution is interrupted. This mask cannot be used to trace memory configurations or other errors.
E_PARSE parsing errors from syntax.
E_CORE_ERROR is similar to E_ERROR, but does not include errors caused by the PHP core.
E_CORE_WARNING is similar to E_WARNING, but does not include PHP core error warnings.


Getenv
Obtain system environment variables
Syntax: string getenv (string varname );
Return Value: String
Function types: PHP system functions
Description: if the environment variable varname is obtained correctly, the variable value is returned. Otherwise, false is returned.
Example
In the following example, you can obtain the URL of the machine where your browser is located.
<?
$ Ip = getenv ("REMOTE_ADDR ");
?>

Get_cmd_var
Obtain the PHP configuration option value.
Syntax: string get_cfg_var (string varname );
Return Value: String
Function types: PHP system functions
Description: if the current PHP configuration option varname is obtained correctly, the variable value is returned. Otherwise, false is returned.

Get_current_user
Obtain the name of the PHP itinerary owner.
Syntax: string get_current_user (void );
Return Value: String
Function types: PHP system functions
Description: This function is used to obtain the name of the owner of the PHP program itinerary.
Reference: getmyuid () getmypid () getmyinode () getlastmod ()

Get_magic_quotes_gpc
Obtain the value of the PHP environment variable magic_quotes_gpc.
Syntax: long get_magic_quotes_gpc (void );
Return Value: Long Integer
Function types: PHP system functions
Description: This function obtains the magic_quotes_gpc (GPC, Get/Post/Cookie) value configured in the PHP environment. If 0 is returned, this function is disabled. If 1 is returned, this function is enabled. When magic_quotes_gpc is enabled, all '(single quotation marks),' (double quotation marks), (backslash), and null characters are automatically converted to overflow characters containing the backslash.
Reference: get_magic_quotes_runtime () set_magic_quotes_runtime ()

Get_magic_quotes_runtime
Obtain the value of the PHP environment variable magic_quotes_runtime.
Syntax: long get_magic_quotes_runtime (void );
Return Value: Long Integer
Function types: PHP system functions
Description: This function obtains the magic_quotes_runtime variable configured in the PHP environment. If 0 is returned, this function is disabled. If 1 is returned, this function is enabled. If magic_quotes_runtime is enabled, all externally introduced database data or files will be automatically converted to materials containing backslash overflow characters.
Reference: get_magic_quotes_gpc () set_magic_quotes_runtime ()

Getlastmod
Returns the last modification time of the webpage.
Syntax: int getlastmod (void );
Return Value: integer
Function types: PHP system functions
Description: This function returns the last modification time of the function webpage. the UNIX timestamp format is returned. The return value can be formatted using the 4.7.2 date () function. If the execution fails, false is returned.

Example: the return value in the following example is similar to 'last modification time on this page: June 19 1999 20:43:59 .'
<? Php
Echo "last modification time on this page:". date ("F d y h: I: s.", getlastmod ());
?>
Reference: date () getmyuid () get_current_user () getmyinode () getmypid ()

Getmyinode
Returns the inode value of the webpage.
Syntax: int getmyinode (void );
Return Value: integer
Function types: PHP system functions
Description: This function returns the inode value of the webpage. If the execution fails, false is returned.
Reference: getmyuid () get_current_user () getmypid () getlastmod ()

Getmypid
Returns the PHP itinerary code.
Syntax: int getmypid (void );
Return Value: integer
Function types: PHP system functions
Description: This function returns the PHP travel code value (PID ). If the execution fails, false is returned. When PHP uses the Apache module, the returned PID value is not necessarily correct.
Reference: getmyuid () get_current_user () getmyinode () getlastmod ()

Getmyuid
Returns the PHP user code.
Syntax: int getmyuid (void );
Return Value: integer
Function types: PHP system functions
Description: This function returns the PHP user code (UID ). If the execution fails, false is returned.
Reference: getmypid () get_current_user () getmyinode () getlastmod ()

Getrusage
Returns the system resource usage.
Syntax: array getrusage (int [who]);
Returned value: Array
Function types: PHP system functions
Description: This function uses a UNIX System Call getrusage (2 ). The returned information is returned as an array. If the parameter who is 1, this function calls RUSAGE_CHILDREN. For more information, see the files in the UNIX function library.
Example
<? Php
$ Dat = getrusage ();
Echo $ dat ["ru_nswap"]; // Number of Swaps
Echo $ dat ["ru_majflt"]; // number of minutes
Echo $ dat ["ru_utime. TV _sec"]; // usage time (seconds)
Echo $ dat ["ru_utime. TV _usec"]; // usage time (MS)
?>

Phpinfo
Returns all PHP information.
Syntax: int phpinfo (void );
Return Value: integer
Function types: PHP system functions
Description: This function returns all PHP information. Including PHP compilation options and expansion configuration, PHP version, server information and environment variables, PHP environment variables, operating system version information, path and environment variable configuration, HTTP header, and copyright notice.
Reference: phpversion ()

Phpversion
Returns the PHP version information.
Syntax: string phpversion (void );
Return Value: String
Function types: PHP system functions
Description: This function returns the PHP version information.
Example
The return value in the following example is similar to 'php version used on this site: 3.0.11'
<? Php
Echo "PHP version used on this site:". phpversion ();
?>
Reference: phpinfo ()

Putenv
Configure system environment variables.
Syntax: void putenv (string setting );
Return Value: None
Function types: PHP system functions
Description: This function is used to configure system environment variables.
Example
The environment variable NLS_LANG to be used to configure the Oracle database. The returned data contains the Chinese BIG5 code. <?
Putenv ("NLS_LANG = american_taiwan.zht16big5 ");
?>
Set_magic_quotes_runtime
Configure the magic_quotes_runtime value.
Syntax: long set_magic_quotes_runtime (int new_setting );
Return Value: Long Integer
Function types: PHP system functions
Description
This function is used to configure the magic_quotes_runtime value.
Reference: get_magic_quotes_gpc () get_magic_quotes_runtime ()

Set_time_limit
Configure the longest execution time for this page.
Syntax: void set_time_limit (int seconds );
Return Value: None
Function types: PHP system functions
Description: This function is used to configure the longest execution time of the page. The default value is 30 seconds. in php. ini, The max_execution_time variable is configured. If it is set to 0, the maximum time is not limited. Computing starts only when the function is executed. For example, if the default value is 30 seconds, and 25 seconds have been executed before the function is executed, and the function is changed to 20 seconds, the maximum execution time of the page is 45 seconds.

Related Article

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.