Home >Backend Development >PHP Tutorial >Summarize some php information functions for you_php skills
Some function concepts included in PHP information functions are summarized as follows.
PHP information function getenv
Applicable versions: PHP3, PHP4
Function function: Get the value of the environment variable.
Function syntax: string getenv (string varname)
Function description: This function can return the value of PHP's environment variable. You can use this function to obtain relevant data.
Sample program:
< ?PHP $ip=getenv ("REMOTE_ADDR"); echo "客户端的 IP 是:".$IP; ?>
Execution result: This result varies from user to user.
PHP information function get_current_user
Applicable versions: PHP3, PHP4
Function: Get the name of the owner of this PHP program code.
Function syntax: string get_current_user (void)
Function description: Get 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 from user to user.
PHP information function getlastmod
Applicable versions: PHP3, PHP4
Function: Get the last updated time of this web page.
Function syntax: int getlastmod (void)
Function description: Get the time when the web page content was last updated on the web page currently in use.
Sample program:
< ?PHP echo "网页最后更新时间:".date ("F d Y H:i:s,getlastmod()); ?>
Execution result: Webpage last updated: January 31 2015 19:51:30
PHP information function getrusage
Applicable versions: PHP3, PHP4
Function: Obtain system resource usage status.
Function syntax: array getrusage (int [who])
Function description: Get the current system resource usage status and return it in the form of an array. For related parameters, please refer to 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 results: Different results may appear depending on the user’s situation
PHP information function phpinfo
Applicable versions: PHP3, PHP4
Function: Display all relevant information in the PHP system
Function syntax: int phpinfo ([int what])
Function description: Display a large amount of information about the current PHP status, including PHP options, extended functions, version, server information, module environment, environment parameters, operating system version, path... and other information. The output results can be changed by specifying one or more of the following settings. If no parameters are filled in at all, all information will be 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
Reference command: phpversion()
PHP information function phpversion
Applicable versions: PHP3, PHP4 Function: Get the version information of the PHP system.
Function syntax: string phpversion (void)
Function description: Return the executing PHP interpreter version as a string.
Sample program:
< ?php echo "PHP" 软件版本: ".phpversion(); ?>
Execution result: PHP software version: 4.0.3 Reference command: phpinfo()
PHP information function set_time_limit
Applicable versions: PHP>=4.0.4, PHP4
Function: Limit the maximum execution time.
Function syntax: void set_time_limit (int seconds)
Function description: Limit the number of seconds that this PHP program can be executed. If the execution time of the program reaches the set number of seconds, a fatal error message will be generated and the execution of the program will be interrupted.
The default time limit is 30 seconds. The execution time calculation method is: the calculation starts when the program is read and executed. Therefore, if the setting time is 20 seconds, but it takes 25 seconds to load and execute, the total It takes 45 seconds for the web page 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 the editor. I hope it will be helpful to everyone's learning.