Somebody recently asked me how to print the PHP version from within the PHP script. The answer is very simple and requires only two words to print the PHP version. Here is the script
<?php
echo PHP_VERSION;
?>
PHP_VERSION is a predefined constant. It contains the value of the PHP version.
A sample output is as follows.
[sudheer@localhost cli]$ php php_version.php 5.2.6 [sudheer@localhost cli]$
You can also use the function phpversion() to print version number of PHP and the extensions enabled.
<?php
echo "The PHP version is " . phpversion();
?>
Post new comment