How to find the version of PHP in macOS?

Recently I tried to launch a simple PHP website from my MacBook. I was able to launch the website using the in-built PHP server on macOS. I got curious to find the version of PHP available in macOS. Here are the different ways you can check the PHP version.

Using the Terminal

The easiest way to check the PHP version is by running a simple command from the terminal.

Launch the terminal, type in and run the command:

php -v

You will get a result similar to the one below. As I’m using macOS Big Sur, It’s showing a warning and an information saying to be removed in future macOS. So, PHP may not be available in macOS Monterey or higher.

WARNING: PHP is not recommended
PHP is included in macOS for compatibility with legacy software.
Future versions of macOS will not include PHP.
PHP 7.3.29-to-be-removed-in-future-macOS (cli) (built: Sep  6 2021 05:14:39) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.29, Copyright (c) 1998-2018 Zend Technologies
Finding version of PHP in macOS using Terminal

While starting a PHP server

You can also check the version of PHP in macOS while starting the in-build PHP server.

To start the PHP server use the below command from the terminal opened from the folder containing the PHP source code. (For more details, see my previous article on starting PHP server)

php -S localhost:9000

Once the PHP server is started, you will get an output similar to the following. In that, you can find the version of PHP.

PHP 7.3.29-to-be-removed-in-future-macOS Development Server started at Thu Sep  8 15:21:20 2022
Listening on http://localhost:9000
Document root is /Users/BeaulinTwinkle
Press Ctrl-C to quit.
Finding version of PHP in macOS while starting PHP server

Using phpinfo() function

phpinfo() is a PHP function, which displays the details about the configuration of PHP on the server. To use phpinfo(), you just create a php file (like php-info.php) and add the below code.


Then follow the above method to start the PHP server from the folder where the file is located. Finally, access the file from the browser as http://localhost:9000/php-info.php. You will see the webpage similar to the one below with a lot of details. On the top left, you will find the version of PHP.

Finding version of PHP in macOS using phpinfo function


Leave your thoughts...

This site uses Akismet to reduce spam. Learn how your comment data is processed.