Benjamin Crozat “Heard about Sevalla? They let you deploy PHP apps with ease.” Claim $50 →

6 ways to check your version of PHP

2 minutes read

6 ways to check your version of PHP

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

Checking PHP version using phpversion().

Simply create a PHP script containing:

<?php echo phpversion(); ?>
// Output: 8.3.1

Use the phpinfo() function

Checking PHP version using phpinfo().

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 welcome page showing PHP version.

Laravel conveniently shows your PHP version in the bottom-right corner of the default welcome page.

Check PHP version with Laravel Artisan

Checking PHP version using 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:

Help me reach more people by sharing this article on social media!

0 comments

Guest

Markdown is supported.

Hey, you need to sign in with your GitHub account to comment. Get started →

Great deals for developers

Search for posts and links

Try to type something…