Home Backend Development PHP Tutorial 为你总结一些php信息函数_PHP

为你总结一些php信息函数_PHP

May 30, 2016 am 08:44 AM
php time function

PHP信息函数包含的一些函数概念总结如下。

PHP信息函数之getenv

适用版本:PHP3, PHP4
函数功能:取得环境变量数值。
函数语法:string getenv (string varname)
函数说明:这个函数能够返回 PHP 的环境变量数值, 可以利用这个函数取得相关数据。
范例程序:

< &#63;PHP 
$ip=getenv ("REMOTE_ADDR"); 
echo "客户端的 IP 是:".$IP; 
&#63;>
Copy after login

执行结果:此结果因用户不同而不同。

PHP信息函数之get_current_user

适用版本:PHP3, PHP4
函数功能:取得这个 PHP 程序代码拥有者的名字。
函数语法:string get_current_user (void)
函数说明:取得目前使用中 PHP 程序代码拥有者的名字。
范例程序:

< &#63;PHP 
echo get_current_user(); 
&#63;>
Copy after login

执行结果:此结果因用户不同而不同。

PHP信息函数之getlastmod

适用版本:PHP3, PHP4
函数功能:取得这个网页最后更新的时间。
函数语法:int getlastmod (void)
函数说明:取得目前使用中网页最后一次更新网页内容的时间。
范例程序:

< &#63;PHP 
echo "网页最后更新时间:".date ("F d Y H:i:s,getlastmod()); 
&#63;> 
Copy after login

执行结果:网页最后更新时间:January 31 2015 19:51:30

PHP信息函数之getrusage

适用版本:PHP3, PHP4
函数功能:取得系统资源使用状况。
函数语法:array getrusage (int [who])
函数说明:取得目前系统资源使用状况, 以数组的形式返回, 相关参数请参考系统的操作手册 getrusage(2)。
范例程序:

< &#63;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) 
&#63;> 
Copy after login

执行结果:依据用户的状况不同而出现不同的结果

PHP信息函数之phpinfo

适用版本:PHP3, PHP4
函数功能:显示 PHP 系统中所有的相关信息
函数语法:int phpinfo ([int what])
函数说明:显示关于目前PHP 状态的大量信息,这些信息包括PHP 的选项、延伸功能、版本、服务器信息、模块环境、环境参数、操作系统版本、路径…等信息。输出的结果可以通过指定下列一个或多个的设置而改变。如果完全不填入参数,则会将全部的信息显示。
范例程序:

< &#63;php 
echo phpinfo(INFO_GENERAL); 
&#63;> 
Copy after login

执行结果:

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

参考命令:phpversion()

PHP信息函数之phpversion

适用版本:PHP3, PHP4 函数功能:取得 PHP 系统的版本信息。
函数语法:string phpversion (void)
函数说明:将正在执行中的 PHP 解释器版本以字符串的类型返回。
范例程序:

< &#63;php 
echo "PHP" 软件版本: ".phpversion(); 
&#63;> 
Copy after login

执行结果:PHP 软件版本: 4.0.3 参考命令:phpinfo()

PHP信息函数之set_time_limit

适用版本:PHP>=4.0.4, PHP4
函数功能:限制最长执行时间。
函数语法:void set_time_limit (int seconds)
函数说明:限制这个 PHP 程序所能执行的秒数, 假如程序执行的时间到设置的秒数, 将会产生一个fatal error 的错误信息, 并且中断程序的执行。

内定的时间限制是30 秒, 执行时间计算的方法是:程序被读取完成并且被执行时就开始计算, 因此如果设置时间是 20 秒,但是花费了 25 秒载入及执行, 总共必须花费 45 秒网页才被中断执行。如果时间设为0表示没有时间限制。

以上就是小编整理的全部php时间函数,希望对大家的学习有所帮助。

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Apr 05, 2025 am 12:04 AM

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

Describe the SOLID principles and how they apply to PHP development. Describe the SOLID principles and how they apply to PHP development. Apr 03, 2025 am 12:04 AM

The application of SOLID principle in PHP development includes: 1. Single responsibility principle (SRP): Each class is responsible for only one function. 2. Open and close principle (OCP): Changes are achieved through extension rather than modification. 3. Lisch's Substitution Principle (LSP): Subclasses can replace base classes without affecting program accuracy. 4. Interface isolation principle (ISP): Use fine-grained interfaces to avoid dependencies and unused methods. 5. Dependency inversion principle (DIP): High and low-level modules rely on abstraction and are implemented through dependency injection.

How to automatically set permissions of unixsocket after system restart? How to automatically set permissions of unixsocket after system restart? Mar 31, 2025 pm 11:54 PM

How to automatically set the permissions of unixsocket after the system restarts. Every time the system restarts, we need to execute the following command to modify the permissions of unixsocket: sudo...

How to debug CLI mode in PHPStorm? How to debug CLI mode in PHPStorm? Apr 01, 2025 pm 02:57 PM

How to debug CLI mode in PHPStorm? When developing with PHPStorm, sometimes we need to debug PHP in command line interface (CLI) mode...

How to send a POST request containing JSON data using PHP's cURL library? How to send a POST request containing JSON data using PHP's cURL library? Apr 01, 2025 pm 03:12 PM

Sending JSON data using PHP's cURL library In PHP development, it is often necessary to interact with external APIs. One of the common ways is to use cURL library to send POST�...

Explain late static binding in PHP (static::). Explain late static binding in PHP (static::). Apr 03, 2025 am 12:04 AM

Static binding (static::) implements late static binding (LSB) in PHP, allowing calling classes to be referenced in static contexts rather than defining classes. 1) The parsing process is performed at runtime, 2) Look up the call class in the inheritance relationship, 3) It may bring performance overhead.

Explain the concept of late static binding in PHP. Explain the concept of late static binding in PHP. Mar 21, 2025 pm 01:33 PM

Article discusses late static binding (LSB) in PHP, introduced in PHP 5.3, allowing runtime resolution of static method calls for more flexible inheritance.Main issue: LSB vs. traditional polymorphism; LSB's practical applications and potential perfo

See all articles