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 info function getenv applicable version: PHP3, PHP4 function: Get environment variables... "> <LINKhref =" http://www.php100.com//statics

 

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.

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:

  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: obtains the name of the PHP code owner currently in use.
Sample 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: gets the last time the webpage content is updated on the currently used webpage.
Sample 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 functions: obtain the usage status 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 relevant parameters, see the system operation manual getrusage (2 ). Sample 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 version: PHP3, PHP4 function: display 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, this information includes PHP options, extended functions, versions, server information, module environment, environment parameters, operating system version, path... . 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 sample 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

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:


  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 limit. 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 is set to the 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.