$version = phpversion();
print $version;
Documentation
However, for best practice, I would use the constant PHP_VERSION. No function overhead, and cleaner IMO.
Also, be sure to use version_compare() if you are comparing PHP versions for compatibility.
$version = phpversion();
print $version;
Documentation
However, for best practice, I would use the constant PHP_VERSION. No function overhead, and cleaner IMO.
Also, be sure to use version_compare() if you are comparing PHP versions for compatibility.
Technically the best way to do it is with the constant PHP_VERSION as it requires no function call and the overhead that comes with it.
php 5
echo $PHP_VERSION;
That does not work in 7+ however, you can use:
php7.x
echo PHP_VERSION;
Not sure about php8.x though. constants are always faster then function calls.
hi, I'm new to PHP.
I want to change display_errors to On for debugging, but see many PHP versions installed.
I thought going to http://localhost/first/index.php?language=English&page=phpinfo would give me the version , but it just renders the regular index page.
Ty.
How to check PHP version?
Is it difficult/risky to update php version?
Should I update from PHP 7.4 ?
PHP-Update from 7.4 to 8.1/8.2 - How much you charge?
Videos
If you are using the PHP CLI, then try using theese shell commands (i'm assuming that you are using linux here)
which php - will locate the php executable (this should be the default php used by you)
whereis php - The first path displayed will be the location of the php executable
echo $PATH - will print a list of paths separated by ":" where the system looks for commands
If you are using PHP as an Apache module then phpinfo() will tell you the php version used, and the php config files, NOT the php path. If you have 2 versions of the php executable then this will help you. If they are the same version then it wont really matter which one is who:)
If you want to find out the php version, then php -v will print the php version in the CLI and any Zend modules installed.
If you want to find out the ini files included then php --ini will display th list of ini files loaded by the php module (this applies for the CLI version).
Just add a simple script
<?php phpinfo(); ?>