This is because VM Code still checking /usr/bin/php directory which is php5

You have to configure the path to the PHP executable in the user settings file. Follow the following steps to change it

  1. Go to File > Preferences > User Settings > Settings.json
  2. Change the value of php.validate.executablePath according to the installed directory of php7.

    "php.validate.executablePath": "/Applications/MAMP/bin/php/php7.0.14/bin/php"

  3. Relaunch VM Code

  1. If the problem remains same, then add the path to PHP7 to your environment variables, run where php and php --version to verify. To add path in your macos sierra do the following:

    • Within the Terminal, run vim ~/.bash_profile
    • Type i and then paste the following at the top of the file:

      export PATH=/user/local/bin:$PATH
      
    • Hit ESC, Type :wq, and hit Enter.

    • In Terminal run source ~/.bash_profile
    • In Terminal, type in which php again and look for the updated string.
    • If everything went successful, it should output the new path to MAMP PHP install.
    • In case it doesn't output the correct path, try closing the terminal window (exit fully) and open again, it should apply the changes (Restart in short)
Answer from Prashant Pokhriyal on Stack Overflow
๐ŸŒ
Benjamin Crozat
benjamincrozat.com โ€บ home โ€บ blog โ€บ check php version: command line and browser methods
6 ways to check your version of PHP in 2025 - Benjamin Crozat
August 11, 2025 - To check your PHP version, run php -v in your terminal. The first line shows your current version immediately. If you cannot use the terminal, phpinfo(), phpversion(), and Laravelโ€™s php artisan about command are the next easiest options.
Discussions

macos - PHP version shown in command line differs from phpinfo(); in localhost:8000 - Ask Different
I started my OS X PHP test server by typing php -S localhost:8000 I updated my PHP on OS X to 5.6 and when I check the version through the command line by typing: php -v It tells me that I have "... More on apple.stackexchange.com
๐ŸŒ apple.stackexchange.com
February 12, 2015
How to check PHP version?
The URL given is one that works with the script they provide or expect you to write. There's no built-in "magic URL" to show that information with PHP. A HTML page of configuration information can be generated in PHP code using phpinfo() You may also want to pay attention to the top section of phpinfo() output that lists the ini files read, to make sure you're editing the right files. This same information is available on the command line through the following commands: php -i (full information similar to phpinfo()) php -m (enabled modules / extensions) php -v (version) php --ini (ini files read) See also php --help for more command-line options. Note that you can also set most ini settings at runtime in a script using ini_set() . In this specific case see also the error_reporting() function. More on reddit.com
๐ŸŒ r/PHPhelp
6
1
November 4, 2023
macos - How can I easily switch between PHP versions on Mac OSX? - Stack Overflow
Switch to PHP ver. 7.2: phpv 7.2 (and you will need to enter your Mac login or sudo password) Switch to PHP ver. 8.2: phpv 8.2 ยท Double-check which version of PHP you are using in your terminal: php -v More on stackoverflow.com
๐ŸŒ stackoverflow.com
macos - Updating php version on mac - Stack Overflow
You can also change the version to 7.0 by replacing the command from above commands from brew install php@71 to brew install php@70. You can check the output by command. More on stackoverflow.com
๐ŸŒ stackoverflow.com
๐ŸŒ
PhoenixNAP
phoenixnap.com โ€บ home โ€บ kb โ€บ sysadmin โ€บ how to check php version
How to Check PHP Version | phoenixNAP KB
December 9, 2025 - This section outlines the steps to check your PHP version from the command line on Windows, Linux, and macOS.
๐ŸŒ
Wikihow
wikihow.com โ€บ computers and electronics โ€บ software โ€บ web programming โ€บ how to check php version: 3 ways on windows, mac, & linux
How to Check PHP Version: 3 Ways on Windows, Mac, & Linux
December 3, 2025 - If you have command line access on the server on which PHP is installed, you can check the PHP version using the command php -v. If the server is remote, you may need to SSH in. First, open your command line interface: Windows Command Prompt: ...
๐ŸŒ
Envato Tuts+
code.tutsplus.com โ€บ home โ€บ php โ€บ php scripts
How to Check the PHP Version | Envato Tuts+
June 30, 2020 - In this section, weโ€™ll discuss how you could check the PHP version by using the command-line interface (CLI) in a terminal. For *nix-based systemsโ€”Linux, Unix, and macOSโ€”it just takes a single command to check the PHP version.
๐ŸŒ
Robots.net
robots.net โ€บ tech โ€บ how-to-check-php-version-mac
How To Check PHP Version Mac | Robots.net
November 30, 2023 - Learn how to easily check the PHP version on your Mac and ensure compatibility for your applications. Follow our step-by-step guide today!
Find elsewhere
๐ŸŒ
ThoughtCo
thoughtco.com โ€บ what-version-of-php-running-2694207
Here's How to Check the Version of PHP You're Running
September 20, 2018 - Below is how to check the locally installed version of PHP. You can run this in Command Prompt in Windows or Terminal for Linux/macOS.
๐ŸŒ
Reddit
reddit.com โ€บ r/phphelp โ€บ how to check php version?
r/PHPhelp on Reddit: How to check PHP version?
November 4, 2023 -

hi, I'm new to PHP.

I want to change display_errors to On for debugging, but see many PHP versions installed.

I thought going to http://localhost/first/index.php?language=English&page=phpinfo would give me the version , but it just renders the regular index page.

Ty.

๐ŸŒ
Envato Tuts+
code.tutsplus.com โ€บ tutorials โ€บ how-to-check-the-php-version--cms-35322
How to Check the PHP Version - Code
July 30, 2020 - Whether you need to create an email form, add a shopping cart to your eCommerce store, or create a contact form with validation, there's a PHP script that's...
๐ŸŒ
Medium
medium.com โ€บ @smile2gether โ€บ how-to-update-php-version-on-mac-os-x-5d4b91b2c1f4
How to update PHP version on Mac OS X | by Smile2gether | Medium
January 11, 2020 - sudo chown -R$(whoami) /usr/local/* brew list | while read f; do brew unlink f; brew link $f; done brew unlink php<<current_php_version>> brew link --overwrite php<<new_php_version>>
๐ŸŒ
DEV Community
dev.to โ€บ micmath โ€บ manage-multiple-versions-of-php-with-homebrew-4dba
Manage Multiple Versions of PHP with Homebrew - DEV Community
October 15, 2022 - The syntax for specifying a specific version of a package with Homebrew is brew install <packageName>@<version>. In this case the package name is php and the version is 7.4 (defaulting to 7.4.32 as of this writing). If you leave off the @<version> part entirely, Homebrew will install whatever the latest version available is (8.1 as of this writing). To check that version 7.4 of php is correctly installed:
๐ŸŒ
Medium
medium.com โ€บ @kczereczon โ€บ use-brew-to-manage-your-php-version-on-macos-33860fe9c74d
Use brew to manage your PHP version on MacOS | by Krzysztof Czereczon | Medium
October 13, 2023 - Use brew to manage your PHP version on MacOS Introduction In this article, I will try to demonstrate how to easily manage PHP versions using Brew in a macOS system. Background I noticed that many โ€ฆ
๐ŸŒ
PHP
php.net โ€บ manual โ€บ en โ€บ install.macosx.bundled.php
PHP: Using the bundled PHP prior to macOS Monterey - Manual
Open up the terminal, read the command line section of the PHP manual, and execute php -v to check the PHP version of this PHP binary.
๐ŸŒ
DevGenius
blog.devgenius.io โ€บ switching-php-versions-on-macos-using-homebrew-2ee3058c8239
Switching PHP Versions on macOS using Homebrew | by Himanshu Gautam | Dev Genius
February 5, 2026 - To confirm that the switch was successful, open a new Terminal window and check the PHP version: ... This should display PHP 7.4.x as the active version. Sometimes we need to close the terminal and start again. Switching PHP versions on macOS is a straightforward process with Homebrew.
๐ŸŒ
GitHub
gist.github.com โ€บ irazasyed โ€บ 5987693
Instructions on how to change preinstalled Mac OS X PHP to MAMP's PHP Installation and then install Composer Package Management ยท GitHub
This should output the path to the default PHP install which comes preinstalled by Mac OS X, by default it has to be (Assuming you've not changed it before): ... Now, We just need to swap this over to the PHP that is installed with MAMP, which is located at /Applications/MAMP/bin/php/php5.4.10/bin (MAMP 2.1.3) To do this, We need to edit the .bash_profile and add the MAMP version of PHP to the PATH variable.
๐ŸŒ
Medium
inyomanjyotisa.medium.com โ€บ 6-ways-to-identify-your-php-version-6d7da6d80b2c
6 Ways to Identify Your PHP Version | by I Nyoman Jyotisa | Medium
November 5, 2024 - To quickly find out which PHP version is running, use the php -v command. This command works across macOS, Linux, and Windows systems.