Check PHP Version

Check PHP Version

When working with PHP, whether you're developing a website or troubleshooting an application, knowing the PHP version is essential. Different PHP versions support different features, and newer versions typically offer better performance and security improvements. This tutorial explains how to check PHP version.

1. 'version' option

If you have access via command line, you can check the PHP version by using command with version option (or the -v shortcut):

php --version
php -v

This will display the PHP version installed on the system along with additional details like build information.

PHP 8.4.1 (cli) (built: Nov 20 2024 11:13:29) (ZTS Visual C++ 2022 x64)
Copyright (c) The PHP Group
Zend Engine v4.4.1, Copyright (c) Zend Technologies

2. 'PHP_VERSION' constant

Another quick way to check the PHP version is by using the built-in PHP_VERSION constant. Here's how:

<?php

$version = PHP_VERSION;
echo $version;

3. 'phpversion' function

You can also check the PHP version using the phpversion function. Here's an example:

<?php

$version = phpversion();
echo $version;

Leave a Comment

Cancel reply

Your email address will not be published.