Check php version xampp windows, linux ubuntu, mac; In this tutorial, you will learn how to check php in Windows 11|10 Xampp, Ubuntu 20.04|22.04 and Mac using command prompt or cmd and PHP script.
PHP is a popular programming language used for web development. If you are a developer or a system administrator, it’s important to know which version of PHP is installed on your system. In this article, we’ll show you how to check the PHP version using different methods.
How to Check PHP Version in Windows 11|10 Xampp, Ubuntu 20.04|22.04 cmd/terminal
Using the following methods, you can check PHP version in Windows 11|10 Xampp, Ubuntu 20.04|22.04, and mac; are as follows:
Method 1: Using the Command Line Interface
The easiest way to check the PHP version on your system is by using the command line interface (CLI). Follow these steps:
- Open the command prompt (Windows) or terminal (ubuntu Linux/Mac).
- Type the following command and press Enter:
php -v
- The PHP version installed on your system will be displayed in the output. Example output:
PHP 7.4.23 (cli) (built: Jan 2 2024 16:11:53) ( NTS ) Copyright (c) The PHP Group Zend Engine v3.4.0, Copyright (c) Zend Technologies
Method 2: Using a PHP Script | phpinfo.php
You can also check the PHP version by creating a PHP script and running it on your web server. Follow these steps:
- Create a new file named “phpinfo.php” in the document root directory of your web server.
- Open the file in a text editor and add the following code:
- <?php phpinfo(); ?>
- Save the file and open it in a web browser. For example, if your web server is running on localhost, you can access the file by typing “http://localhost/phpinfo.php” in the browser address bar.
- The PHP version installed on your system will be displayed on the top of the page.
- PHP Version 7.4.23
- System Windows NT LAPTOP-123 10.0 build 19042 (Windows 10) AMD64
- Build Date
Jan 2 2024
16:12:01
Method 3: Using a PHP Framework
If you are using a PHP framework such as Laravel or Symfony, you can check the PHP version by running a command in the terminal. Follow these steps:
- Open the terminal and navigate to the root directory of your PHP project.
- Type the following command and press Enter:
php artisan --version
- The PHP version used by the framework will be displayed in the output.Example output (for Laravel):
Laravel Framework 8.55.0 PHP 7.4.23 (cli) (built: Jan 2 2024 16:11:53) ( NTS ) ...
Here is the video guide for that:
Conclusion
In this tutorial, we have shown you how to check the PHP version on your system using different methods. By knowing the PHP version, you can ensure that your web applications are compatible with the PHP version installed on your server.