Baumeister Mediasoft Engineering BME - Baumeister Mediasoft Engineering  PHP Functions - English Version PHP-Funktionen - Deutsche Version
Baumeister Mediasoft Engineering
Bartels AutoEngineerCarLogServicesResourcesCompany ProfileContact Us
Baumeister Mediasoft Engineering » Resources » Web Development » PHP » Functions
PHP - PHP Hypertext Preprocessor

PHP Functions

PHP - PHP Hypertext Preprocessor

Sitemap

Last Change

PHP Functions 
PHP Function phpinfo (INFO) 02/10/2010
PHP Function phpversion (INFO) 02/10/2010
 

PHP Function phpinfo (INFO)

phpinfo() creates a web page with comprehensive system environment information such as operating system and web server environment, PHP configuration, paths, global and local values of configuration options, HTTP headers, etc. Because every system is setup differently, phpinfo() is often used to check configuration settings and predefined system variables. phpinfo() is also a valuable debugging tool as it lists GET, POST, cookie, environment and server data.

It doesn't come as a surprise that the following script is often the first PHP script a PHP developer runs on a new client system:

<?php
phpinfo
();
?>

The above script is usually saved under a file name such as phpinfo.php. Since phpinfo() exposes information which might help hackers to break into a system, it is not recommended to provide easy and/or permanent public access to phpinfo() scripts.

PHP Function phpversion (INFO)

The phpversion() retrieves the current PHP version:

<?php
echo '<p>PHP Version: '.phpversion().'</p>';
?>

Output:

PHP Version: 5.6.31

The string returned by phpversion() can easily be converted to a numeric value:

<?php
echo '<p>PHP Version: '.phpversion().' = '.(float)phpversion().'</p>';
?>

Output:

PHP Version: 5.6.31 = 5.6

phpversion() can be used to control the execution of PHP functions with different implementations depending on the PHP version. The following code shows a version-independent application of the microtime() PHP function for retrieving the Unix timestamp with microseconds accuracy:

<?php
function getMicrotime()
{
    
// Get Unix timestamp with microseconds accuracy
    
if ((float)phpversion() >= 5.0)
    {
        return 
microtime(1);
    }
    list(
$usec$sec) = explode(' 'microtime());
    return ((float)
$sec + (float)$usec);
}
?>
Baumeister Mediasoft Engineering » Resources » Web Development » PHP » Functions

PHP Functions • © 2017 Manfred Baumeister

Baumeister Mediasoft Engineering, Clontarf, Dublin 3, Ireland
© 2017 Manfred Baumeister

PHP Functions - English Version PHP-Funktionen - Deutsche Version