
2 minutes read
6 ways to check your version of PHP
Table of contents
Introduction
To quickly check your PHP version, open your terminal and run php -v
. The first line shows your current PHP version (e.g., PHP 8.3.1
).
Here’s a detailed look at 6 easy methods:
Run php -v
in your terminal
This method works perfectly on macOS, Linux, Windows, and WSL.
php -v
This outputs “PHP 8.3.1 (cli) (built: Feb 10 2025 12:00:00)”
Use the phpversion()
function
Simply create a PHP script containing:
<?php echo phpversion(); ?> // Output: 8.3.1
Use the phpinfo()
function
Create a PHP file with:
<?php phpinfo(); ?>
Open this in your browser and find the PHP version at the top.
Check PHP version via Composer
If you use Composer, run this command:
composer --version
Check PHP version using Laravel’s welcome page
Laravel conveniently shows your PHP version in the bottom-right corner of the default welcome page.
Check PHP version with Laravel Artisan
From your Laravel project’s root, run:
php artisan about
You’ll see your PHP version along with other useful details.
FAQ
How do I check my PHP version on macOS?
Run php -v
in your macOS terminal.
How do I check my PHP version on Ubuntu?
Run php -v
in your Ubuntu terminal.
How do I check my PHP version on Windows?
Run php -v
in your Windows command prompt.
Which PHP versions are end-of-life (EOL) in 2025?
PHP 7.x and older are considered EOL in 2025. Upgrade to PHP 8.x to stay secure.
How do I find my PHP version in WordPress?
In the admin panel, go to Tools → Site Health → Info → Server.
Can I have multiple PHP versions installed?
Yes! Tools like Homebrew (macOS), Docker, and version managers allow multiple PHP versions on the same system.
Did you like this article? Then, keep learning:
- Get insights on upcoming PHP 8.4 features and release date
- Overview of Laravel 12-ready books to advance your Laravel skills
- Review recommended PHP developer blogs to stay updated in 2024
- Learn how to lock PHP extensions versions with Composer and Docker
- Understand PHP 8.3's new Override attribute for clearer intent
- Stay updated with PHP 8.3 new features and breaking changes
- Explore PHP array emptiness checking methods to write better code
- Learn to print arrays in PHP and Laravel for easier debugging
- Discover how to reveal all errors in PHP for effective debugging
- Overview of Laravel Artisan command tool to boost development speed
0 comments