PHP options and related information function library _php basics

Source: Internet
Author: User
Tags php compiler phpinfo
Error_log: Send out an error message.
Error_reporting: Configure the level of error message return.
GETENV: Get the environment variable 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 modification time of the page.
Getmyinode: Returns the Inode value for this page.
Getmypid: Return to PHP's itinerary code.
Getmyuid: Returns the user code for PHP.
Getrusage: Returns the system resource utilization rate.
Phpinfo: Return all relevant information about PHP.
Phpversion: Returns the PHP version information.
PUTENV: Configure system environment variables.
Set_magic_quotes_runtime: Configure Magic_quotes_runtime values.
Set_time_limit: Configure 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 will send the error message to the WEB server's error log file, TCP Port, or to the specified file. The first argument message is the error information to send. The second parameter, Message_type, is an integer value: 0 for log (UNIX in Syslog, Windows NT record to event record), and 1 for PHP Mail () to send information to an e-mail, fourth parameter extr A_headers will also be used; 2 The error message is sent to the TCP port, when the third parameter destination represents the destination IP and port;3 the information is stored in the file destination.
Usage examples
This example deals with problems with logging into an Oracle database.
<?php
if (! Ora_logon ($username, $password)) {
Error_log ("Oracle Database not available!", 0);
}
if (!) ( $foo = Allocate_new_foo ()) {
Error_log ("There's been a big problem!", 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 error message return, the parameter level is a bit mask (bitmask) of an integer, see the following table
Mask value indicates 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 logged and is only used when the program has an error condition, such as attempting to access a nonexistent variable, or calling the stat () function to view files that do not exist.
E_warning are usually displayed but do not interrupt the execution of the program. This is very effective for debugging. For example, call Ereg () with a problematic regular expression.
E_error are usually displayed and interrupt the execution of the program. This mask will not be able to trace the memory configuration or other errors.
E_parse parse the error from the syntax.
E_core_error is similar to E_error, but does not include errors caused by the PHP core.
E_core_warning similar to e_warning, but does not include PHP core error warning


Getenv
To obtain the environment variables of the system
Syntax: String getenv (string varname);
return value: String
Function type: PHP system function
Content Description: If the correct access to the environment variable varname, then return the value of the variable. Returns False if it fails.
Usage examples
The following example gets the URL of the machine where the user's browser resides
?
$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 correct access to the current PHP configuration options varname, then return the value of the variable. Returns False if it fails.

Get_current_user
Gets the owner name of the PHP itinerary.
Syntax: string get_current_user (void);
return value: String
Function type: PHP system function
Content 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. A return of 0 indicates that this feature is turned off; 1 indicates that this feature is turned on. When MAGIC_QUOTES_GPC is open, 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
Content Description: This function obtains the PHP environment configuration variable magic_quotes_runtime value. A return of 0 indicates that this feature is turned off; 1 indicates that this feature is turned on. If the magic_quotes_runtime is open, all externally introduced database data or files will automatically be converted into data containing backslash overflow characters.
Reference: GET_MAGIC_QUOTES_GPC () set_magic_quotes_runtime ()

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

Usage Example: The following example returns a value similar to ' this page last modified: June 19 1999 20:43:59. '
<?php
echo "Last modified on this page:". Date ("F D Y h:i:s.", Getlastmod ());
?>
Reference: Date () Getmyuid () Get_current_user () Getmyinode () Getmypid ()

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

Getmypid
Return the PHP travel code.
Syntax: int getmypid (void);
return value: Integer
Function type: PHP system function
Description: This function returns the PHP travel code value (PID). Returns the value of False if execution fails. When PHP exists 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
Content Description: This function returns the user code (UID) of PHP. Returns the value of False if execution fails.
Reference: Getmypid () Get_current_user () Getmyinode () Getlastmod ()

Getrusage
Returns the utilization rate of system resources.
Syntax: array getrusage (int [who]);
return value: Array
Function type: PHP system function
Description: This function uses UNIX's 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 referenced in UNIX function library files.
Usage examples
<?php
$dat = Getrusage ();
echo $dat ["Ru_nswap"]; Number of Swaps
echo $dat ["Ru_majflt"]; Page-Numbering
echo $dat ["ru_utime.tv_sec"]; Use Time (seconds)
echo $dat ["ru_utime.tv_usec"]; Usage time (MS)
?>

Phpinfo
Return all relevant information about PHP.
Syntax: int phpinfo (void);
return value: Integer
Function type: PHP system function
Description: This function returns all of the information in PHP. Includes PHP compiler options and expansion configuration, 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 '
<?php
echo "This site uses PHP version:". Phpversion ();
?>
Reference: Phpinfo ()

Putenv
Configure 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 environment variable Nls_lang to use for the Oracle database, and return the data containing the Chinese BIG5 code. ?
Putenv ("Nls_lang=american_taiwan.zht16big5");
?>
Set_magic_quotes_runtime
Configure Magic_quotes_runtime values.
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 Magic_quotes_runtime values.
Reference: GET_MAGIC_QUOTES_GPC () Get_magic_quotes_runtime ()

Set_time_limit
Configure 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, the Max_execution_time variable is configured in PHP.ini, and if configured to 0 it is not limited to the longest time. The calculation begins when the function is executed. For example, if the default is 30 seconds and 25 seconds have been executed before executing to the function, and the function is changed to 20 seconds, the maximum execution time for the page is 45 seconds.

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.