Summary of some PHP information function _ PHP Tutorial

Source: Internet
Author: User
Tags php software
Summarize some PHP information functions for you. Getenv □applicable version of the PHP information function: PHP3, PHP4 □function function: obtain the environmental variable value. □Function syntax: stringgetenv (stringvarname) □function Description: This function

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.


Optional □applicable version: PHP3, PHP4 □function: obtain the environmental variable value. □Function syntax: string getenv (string varname) □function Description: This function...

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.