search
HomeBackend DevelopmentPHP Tutorial为你总结一些php信息函数_PHP

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

PHP信息函数之getenv

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

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

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

PHP信息函数之get_current_user

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

< &#63;PHP 
echo get_current_user(); 
&#63;>

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

PHP信息函数之getlastmod

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

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

执行结果:网页最后更新时间: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;> 

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

PHP信息函数之phpinfo

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

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

执行结果:

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;> 

执行结果: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
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
The Continued Use of PHP: Reasons for Its EnduranceThe Continued Use of PHP: Reasons for Its EnduranceApr 19, 2025 am 12:23 AM

What’s still popular is the ease of use, flexibility and a strong ecosystem. 1) Ease of use and simple syntax make it the first choice for beginners. 2) Closely integrated with web development, excellent interaction with HTTP requests and database. 3) The huge ecosystem provides a wealth of tools and libraries. 4) Active community and open source nature adapts them to new needs and technology trends.

PHP and Python: Exploring Their Similarities and DifferencesPHP and Python: Exploring Their Similarities and DifferencesApr 19, 2025 am 12:21 AM

PHP and Python are both high-level programming languages ​​that are widely used in web development, data processing and automation tasks. 1.PHP is often used to build dynamic websites and content management systems, while Python is often used to build web frameworks and data science. 2.PHP uses echo to output content, Python uses print. 3. Both support object-oriented programming, but the syntax and keywords are different. 4. PHP supports weak type conversion, while Python is more stringent. 5. PHP performance optimization includes using OPcache and asynchronous programming, while Python uses cProfile and asynchronous programming.

PHP and Python: Different Paradigms ExplainedPHP and Python: Different Paradigms ExplainedApr 18, 2025 am 12:26 AM

PHP is mainly procedural programming, but also supports object-oriented programming (OOP); Python supports a variety of paradigms, including OOP, functional and procedural programming. PHP is suitable for web development, and Python is suitable for a variety of applications such as data analysis and machine learning.

PHP and Python: A Deep Dive into Their HistoryPHP and Python: A Deep Dive into Their HistoryApr 18, 2025 am 12:25 AM

PHP originated in 1994 and was developed by RasmusLerdorf. It was originally used to track website visitors and gradually evolved into a server-side scripting language and was widely used in web development. Python was developed by Guidovan Rossum in the late 1980s and was first released in 1991. It emphasizes code readability and simplicity, and is suitable for scientific computing, data analysis and other fields.

Choosing Between PHP and Python: A GuideChoosing Between PHP and Python: A GuideApr 18, 2025 am 12:24 AM

PHP is suitable for web development and rapid prototyping, and Python is suitable for data science and machine learning. 1.PHP is used for dynamic web development, with simple syntax and suitable for rapid development. 2. Python has concise syntax, is suitable for multiple fields, and has a strong library ecosystem.

PHP and Frameworks: Modernizing the LanguagePHP and Frameworks: Modernizing the LanguageApr 18, 2025 am 12:14 AM

PHP remains important in the modernization process because it supports a large number of websites and applications and adapts to development needs through frameworks. 1.PHP7 improves performance and introduces new features. 2. Modern frameworks such as Laravel, Symfony and CodeIgniter simplify development and improve code quality. 3. Performance optimization and best practices further improve application efficiency.

PHP's Impact: Web Development and BeyondPHP's Impact: Web Development and BeyondApr 18, 2025 am 12:10 AM

PHPhassignificantlyimpactedwebdevelopmentandextendsbeyondit.1)ItpowersmajorplatformslikeWordPressandexcelsindatabaseinteractions.2)PHP'sadaptabilityallowsittoscaleforlargeapplicationsusingframeworkslikeLaravel.3)Beyondweb,PHPisusedincommand-linescrip

How does PHP type hinting work, including scalar types, return types, union types, and nullable types?How does PHP type hinting work, including scalar types, return types, union types, and nullable types?Apr 17, 2025 am 12:25 AM

PHP type prompts to improve code quality and readability. 1) Scalar type tips: Since PHP7.0, basic data types are allowed to be specified in function parameters, such as int, float, etc. 2) Return type prompt: Ensure the consistency of the function return value type. 3) Union type prompt: Since PHP8.0, multiple types are allowed to be specified in function parameters or return values. 4) Nullable type prompt: Allows to include null values ​​and handle functions that may return null values.

See all articles

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

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.