Summarize some php information functions for you

Source: Internet
Author: User
Tags php software
PHP is a function-based HTML language. Its huge function library can help us achieve many functional requirements. Here we will introduce in detail some function concepts contained in PHP information functions.

PHP is a function-based HTML language. Its huge function library can help us achieve many functional requirements. Here we will introduce in detail some function concepts contained in PHP information functions.

Some functions of PHP information functions are summarized as follows.

Getenv of PHP information functions

Applicable versions: PHP3 and PHP4
Function: obtains the value of an environmental variable.
Function Syntax: string getenv (string varname)
Function Description: This function returns the environmental variable value of PHP. You can use this function to obtain relevant data.
Sample program:

<? PHP $ ip = getenv ("REMOTE_ADDR"); echo "Client IP:". $ IP;?>

Execution result: the result varies with users.

Get_current_user of the PHP information function

Applicable versions: PHP3 and PHP4
Function: get the name of the PHP code owner.
Function Syntax: string get_current_user (void)
Function Description: obtains the name of the PHP code owner currently in use.
Sample program:

<? PHP echo get_current_user ();?>

Execution result: the result varies with users.

Getlastmod of PHP information functions

Applicable versions: PHP3 and PHP4
Function: Obtain the last update time of the webpage.
Function Syntax: int getlastmod (void)
Function Description: gets the last time the webpage content is updated on the currently used webpage.
Sample program:

<? PHP echo "Last Page Update time:". date ("F d y h: I: s, getlastmod ();?>

Execution result: Last Update Time of the webpage: January 31 2015 19:51:30

Getrusage of PHP information functions

Applicable versions: PHP3 and PHP4
Function: obtains the usage of system resources.
Function Syntax: array getrusage (int [who])
Function Description: obtains the current system resource usage status and returns the result in an array. For details about the parameters, see the system operation manual getrusage (2 ).
Sample program:

<? Php $ dat = getrusage (); echo $ dat ["ru_nswap"]; # number of swaps echo $ dag ["ru_majflt"]; # number of page faults echo $ dat ["ru_utime. TV _sec"]; # user time used (seconds) echo $ dat ["ru_utime. TV _usec"]; # user time used (microseconds)?>

Execution result: different results are displayed based on different user conditions.

Phpinfo of PHP information functions

Applicable versions: PHP3 and PHP4
Function: displays all related information in the PHP system.
Function Syntax: int phpinfo ([int what])
Function Description: displays a large amount of information about the current PHP status, including PHP options, extended functions, versions, server information, Module Environment, environment parameters, operating system versions, paths... . The output result can be changed by specifying one or more of the following settings. If no parameter is specified, all information is displayed.
Sample program:

<? Php echo phpinfo (INFO_GENERAL);?>

Execution result:

PHP Version 4.0.3 System Windows 95/98 4.10 Build Date Oct 12 2000 Server api cgi Virtual Directory Support enabled Configuration File (php. ini) Path php. ini ZEND_DEBUG disabled Thread Safety Enabled This program makes use of the Zend scripting language engine: Zend Engine v1.0.3, copyright (c) 1998-2000 zend Technologies

Command: phpversion ()

Phpversion of PHP information functions

Applicable version: PHP3 and PHP4 functions: Obtain the version information of the PHP system.
Function Syntax: string phpversion (void)
Function Description: returns the PHP interpreter version in progress as a string.
Sample program:

<? Php echo "PHP" Software Version: ". phpversion ();?>

Execution result: PHP Software Version: 4.0.3 reference command: phpinfo ()

Set_time_limit of PHP information functions

Applicable versions: PHP> = 4.0.4, PHP4
Function: limits the maximum execution time.
Function Syntax: void set_time_limit (int seconds)
Function Description: limits the number of seconds that the PHP program can execute. If the execution time of the Program reaches the set number of seconds, a fatal error message is generated and the execution of the program is interrupted.

The preset time limit is 30 seconds. The execution time calculation method is: when the program is read and executed, the calculation starts. Therefore, if the execution time is set to 20 seconds, however, it takes 25 seconds to load and execute the website. In total, it takes 45 seconds for the webpage to be interrupted. If the time is set to 0, there is no time limit.

The above are all the php time functions compiled by xiaobian. I hope they will help you in your learning.

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.