Summarize some PHP information function _php Skills for you

Source: Internet
Author: User
Tags php software phpinfo time limit zend

Some of the function concepts included in the PHP information function are summarized below.

The getenv of PHP information function

Applicable version: PHP3, PHP4
function function: Gets the value of the environment variable.
function Syntax: string getenv (String varname)
Function Description: This function can return the value of the environment variables in PHP, you can use this function to obtain relevant data.
Sample program:

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

Execution Result: This result varies by user.

The Get_current_user of PHP information function

Applicable version: PHP3, PHP4
Function: Gets the name of the owner of this PHP program code.
function Syntax: string get_current_user (void)
Function Description: Gets the name of the owner of the PHP program code currently in use.
Sample program:

<? PHP 
Echo Get_current_user (); 
? >

Execution Result: This result varies by user.

The Getlastmod of PHP information function

Applicable version: PHP3, PHP4
Function: Gets the time of the last update of this page.
function syntax: int getlastmod (void)
Function Description: Gets the time that the page content was last updated in the currently used pages.
Sample program:

<? PHP 
echo "page last updated:". Date ("F D Y h:i:s,getlastmod ()); 

Execution Result: Web page last updated: January 31 2015 19:51:30

The Getrusage of PHP information function

Applicable version: PHP3, PHP4
function function: Obtain the system resource usage condition.
function syntax: array getrusage (int [who])
Function Description: Obtain the current system resource usage status, returns in the form of the array, the related parameter please refer to the system's 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 Results: different results depending on the user's condition

The Phpinfo of PHP information function

Applicable version: PHP3, PHP4
function function: Display all the relevant information in the PHP system
function syntax: int phpinfo ([int what])
Function Description: Display a large amount of information about the current state of PHP, including PHP options, extension functions, version, server information, module environment, environment parameters, operating system version, path ... and other information. The results of the output can be changed by specifying one or more of the following settings. If you do not fill in the parameters at all, all the information is displayed.
Sample program:

< PHP 
echo phpinfo (info_general); 

Execution results:

PHP Version 4.0.3 System Windows 95/98 4.10 Build Date Oct Server API CGI Virtual Directory Support enabled Config Uration 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

Reference command: Phpversion ()

The Phpversion of PHP information function

Applicable version: PHP3, PHP4 function: Get the version information of the PHP system.
function Syntax: string phpversion (void)
Function Description: Returns the version of the PHP interpreter that is being executed as a string.
Sample program:

< php 
echo "PHP" software version: ". Phpversion (); 

Execution Results: PHP software version: 4.0.3 reference command: Phpinfo ()

The Set_time_limit of PHP information function

Applicable version: php>=4.0.4, PHP4
function function: Limits the maximum execution time.
function syntax: void set_time_limit (int seconds)
Function Description: Limit the number of seconds the PHP program can perform, if the program is executed to the number of seconds to set, will produce a fatal error message, and interrupt the execution of the program.

The default time limit is 30 seconds, and the execution time is calculated by: The program is read and executed, so if the setting time is 20 seconds, but it takes 25 seconds to load and execute, it must take 45 seconds for the page to be interrupted for execution. If the time set to 0 indicates no time limit.

The above is a small compilation of all the PHP time function, I hope to help you learn.

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.