PHP options and related Information function Library _php Tutorial

Source: Internet
Author: User
Tags php compiler phpinfo server error log
Error_log: Send out an error message.
Error_reporting: Configure the level of return for error messages.
GETENV: Obtaining the environment variables of the system
Get_cfg_var: Gets the configuration option value for PHP.
Get_current_user: Gets the name of the owner of the PHP itinerary.
GET_MAGIC_QUOTES_GPC: Gets 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 modified time of the page.
Getmyinode: Returns the Inode value for this page.
Getmypid: Returns the itinerary designator for PHP.
Getmyuid: Returns the user code for PHP.
Getrusage: Returns system resource usage.
Phpinfo: Returns all relevant information about PHP.
Phpversion: Returns the PHP version information.
PUTENV: Configure system environment variables.
Set_magic_quotes_runtime: Configures the Magic_quotes_runtime value.
Set_time_limit: Configures the page for the longest execution time.

int Error_log
Syntax: int error_log (string message, int message_type, string [destination], string [extra_headers]);
return value: Integer
Function type: PHP system function
Description: This function sends an error message to the WEB Server error log file, TCP Port, or to the specified file. The first parameter, a message, is the error message to send. The second parameter, Message_type, is an integer value: 0 is the log sent to the operating system (UNIX in Syslog, Windows NT record to event record), 1 uses the mail () function of PHP, sends the message to an e-mail, the fourth parameter extr A_headers will also be used; 2 sends the error message to the TCP port, at which point the third parameter destination indicates the destination IP and port;3 the information to the file destination.
Usage examples
This example deals with problems with logging in to the Oracle database.
if (! Ora_logon ($username, $password)) {
Error_log ("Oracle database is not available!", 0);
}
if (! ( $foo = Allocate_new_foo ()) {
Error_log ("Appearing * annoying!", 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 level of error message return.
Syntax: int error_reporting (int [level]);
return value: Integer
Function type: PHP system function
Description: This function is used to configure the level of return of error information, the parameter levels is an integer bit mask (bitmask), see the table below
Mask value represents name
1 E_error
2 e_warning
4 E_parse
8 E_notice
E_core_error
E_core_warning



E_notice indicates that the general situation is not recorded and only used if the program has an error condition, such as attempting to access a nonexistent variable or calling the stat () function to view a nonexistent file.
E_warning are usually displayed, but the execution of the program is not interrupted. This is very effective for debugging. For example: Call Ereg () with a problematic regular expression.
The e_error is usually displayed, and the program execution is interrupted. This mask cannot be traced to a memory configuration or other error.
E_parse parsing errors from the syntax.
E_core_error is similar to E_error, but does not include errors caused by PHP core.
E_core_warning similar to e_warning, but does not include PHP core error warning


Getenv
Get the environment variables of the system
Syntax: String getenv (string varname);
return value: String
Function type: PHP system function
Description: If the environment variable varname is correctly obtained, the value of the variable is returned. The failure returns false.
Usage examples
The following example can get the URL of the machine where the user's browser
$ip = getenv ("REMOTE_ADDR");
?>

Get_cfg_var
Gets the configuration option value for PHP.
Syntax: String Get_cfg_var (string varname);
return value: String
Function type: PHP system function
Content Description: If the current PHP configuration option varname is correctly obtained, the value of the variable is returned. The failure returns false.

Get_current_user
Gets the name of the owner of the PHP itinerary.
Syntax: string get_current_user (void);
return value: String
Function type: PHP system function
Description: This function is used to get the name of the owner of the PHP program itinerary.
Reference: Getmyuid () getmypid () Getmyinode () Getlastmod ()

Get_magic_quotes_gpc
Gets the value of the PHP environment variable MAGIC_QUOTES_GPC.
Syntax: Long get_magic_quotes_gpc (void);
Return value: Long integer
Function type: PHP system function
Content Description: This function obtains the PHP environment configuration variable MAGIC_QUOTES_GPC (GPC, Get/post/cookie) value. Returns 0 to turn off this function; return 1 indicates that this function is turned on. When MAGIC_QUOTES_GPC is turned on, all ' (single quotes), "(double quotes), (backslash) and null characters are automatically converted to overflow characters that contain backslashes.
Reference: Get_magic_quotes_runtime () set_magic_quotes_runtime ()

Get_magic_quotes_runtime
Gets the value of the PHP environment variable magic_quotes_runtime.
Syntax: Long get_magic_quotes_runtime (void);
Return value: Long integer
Function type: PHP system function
Description: This function gets the variable magic_quotes_runtime value of the PHP environment configuration. Returns 0 to turn off this function; return 1 indicates that this function is turned on. If Magic_quotes_runtime is turned on, all external database data or files are automatically converted to data containing backslash overflow characters.
Reference: GET_MAGIC_QUOTES_GPC () set_magic_quotes_runtime ()

Getlastmod
Returns the last modified time of the page.
Syntax: int getlastmod (void);
return value: Integer
Function type: PHP system function
Description: This function returns the last modification time for the page of the function, returns the UNIX timestamp (timestamp) format, and formats the return value using the 4.7.2 date () function. Returns the false value if execution fails.

Example of use: The following example returns a value like ' This page was last modified: June 19 1999 20:43:59. '
echo "This page was last modified:". Date ("F D Y h:i:s.", Getlastmod ());
?>
Reference: Date () Getmyuid () Get_current_user () Getmyinode () Getmypid ()

Getmyinode
Returns the Inode value for the page.
Syntax: int getmyinode (void);
return value: Integer
Function type: PHP system function
Description: This function returns the Inode value for this page. Returns the false value if execution fails.
Reference: Getmyuid () Get_current_user () Getmypid () Getlastmod ()

Getmypid
Returns the itinerary designator for PHP.
Syntax: int getmypid (void);
return value: Integer
Function type: PHP system function
Description: This function returns the travel designator value (PID) of PHP. Returns the false value if execution fails. When PHP is present in the Apache module, the returned PID value is not necessarily correct.
Reference: Getmyuid () Get_current_user () Getmyinode () Getlastmod ()

Getmyuid
Returns the user code for PHP.
Syntax: int getmyuid (void);
return value: Integer
Function type: PHP system function
Description: This function returns the user code (UID) of PHP. Returns the false value if execution fails.
Reference: Getmypid () Get_current_user () Getmyinode () Getlastmod ()

Getrusage
Returns the system resource usage.
Syntax: array getrusage (int [who]);
return value: Array
Function type: PHP system function
Description: This function uses the UNIX system to call Getrusage (2). The returned information is returned as an array. If the parameter who is 1, this function will call Rusage_children. Further information can be found in UNIX library-related files.
Usage examples
$dat = Getrusage ();
echo $dat ["Ru_nswap"]; Number of Swaps
echo $dat ["Ru_majflt"]; Number of pages
echo $dat ["ru_utime.tv_sec"]; Usage time (seconds)
echo $dat ["ru_utime.tv_usec"]; Usage time (MS)
?>

Phpinfo
Returns all relevant information about PHP.
Syntax: int phpinfo (void);
return value: Integer
Function type: PHP system function
Description: This function returns all the information in PHP. Includes PHP compiler options and extensions, PHP version, server information and environment variables, PHP environment variables, operating system version information, path and environment variable configuration, HTTP headers, and copyright announcements.
Reference: Phpversion ()

Phpversion
Returns the PHP version information.
Syntax: string phpversion (void);
return value: String
Function type: PHP system function
Content Description: This function returns the version information of PHP.
Usage examples
The following example returns a value similar to ' This site uses PHP version: 3.0.11 '
echo "This site uses PHP version:". Phpversion ();
?>
Reference: Phpinfo ()

Putenv
Configure the system environment variables.
Syntax: void putenv (string setting);
return value: None
Function type: PHP system function
Content Description: This function is used to configure system environment variables.
Usage examples
Configure the Oracle database to use the environment variable Nls_lang, return the data containing Chinese BIG5 code. Putenv ("Nls_lang=american_taiwan.zht16big5");
?>
Set_magic_quotes_runtime
Configures the Magic_quotes_runtime value.
Syntax: Long set_magic_quotes_runtime (int new_setting);
Return value: Long integer
Function type: PHP system function
Content Description
This function is used to configure the Magic_quotes_runtime value.
Reference: GET_MAGIC_QUOTES_GPC () Get_magic_quotes_runtime ()

Set_time_limit
Configures the page for the longest execution time.
Syntax: void set_time_limit (int seconds);
return value: None
Function type: PHP system function
Description: This function is used to configure the page for the longest execution time. The default value is 30 seconds, and the max_execution_time variable configuration in php.ini, if configured to 0, is not limited to the longest time. The calculation is only started when the function is executed. For example, if the default 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 for the page is 45 seconds.

http://www.bkjia.com/PHPjc/317160.html www.bkjia.com true http://www.bkjia.com/PHPjc/317160.html techarticle error_log: Send out an error message. Error_reporting: Configure the level of return for error messages. GETENV: Get the system environment variable Get_cfg_var: Gets the configuration option value of PHP. Get_current_ ...

  • 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.