Summarize some PHP information functions for you

Source: Internet
Author: User
Tags php software

Getenv of PHP information functions

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

  1. <? PHP
  2. $ Ip = getenv ("REMOTE_ADDR ");
  3. Echo "The Client IP is:". $ IP;
  4. ?> 

□Execution result: the result varies with users.
□Reference command: None

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: Obtain the name of the PHP code owner currently in use.
□Example program:

  1. <? PHP
  2. Echo get_current_user ();
  3. ?> 

□Execution result: the result varies with users.
□Reference command: None

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: Obtain the last time the webpage content is updated in use.
□Example program:

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

□Execution result: Last Update Time of the webpage: January 31 2001 19:51:30
□Reference command: None

Getrusage of PHP information functions

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

 
 
  1. < ?php  
  2. $dat=getrusage();  
  3. echo $dat["ru_nswap"];#number of swaps  
  4. echo $dag["ru_majflt"]; #number of page  
  5. faults  
  6. echo $dat["ru_utime.tv_sec"];#user time  
  7. used (seconds)  
  8. echo $dat["ru_utime.tv_usec"]; #user time  
  9. used (microseconds)  
  10. ?> 

□Execution result: different results are displayed based on different user conditions.
□Reference command: None

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.

INFO_GENERAL
INFO_CREDITS
INFO_CONFIGURATION
INFO_MODULES
INFO_ENVIRONMENT
INFO_VARIABLES
INFO_LICENSE
INFO_ALL
□Example program:

 
 
  1. < ?php  
  2. echo phpinfo(INFO_GENERAL);  
  3. ?> 

□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

□Reference command: phpversion ()

Phpversion of PHP information functions

□Applicable versions: PHP3 and PHP4
□Function: Obtain the version information of the PHP system.
□Function Syntax: string phpversion (void)
□Function Description: returns the PHP interpreter version being executed as a string.
□Example program:

 
 
  1. <? Php
  2. Echo "PHP" software version:
    ". Phpversion ();
  3. ?>

□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: Maximum execution time is limited.
□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. How does one calculate the execution time? The calculation starts when the data is read and executed. Therefore, if the setting time is 20 seconds but it takes 25 seconds to load and execute the data, it takes 45 seconds for the webpage to be interrupted. If the time is set to 0, there is no time limit.


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.