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
Check PHP version: command line and browser methods
September 2, 2023 - 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.
🌐
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
🌐
Envato Tuts+
code.tutsplus.com › tutorials › how-to-check-the-php-version--cms-35322
How to Check the PHP Version - Code
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...
🌐
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.

🌐
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.
🌐
Nerd
nerd.vision › post › changing-php-version-with-valet-and-homebrew-osx
Changing PHP version with Valet and Homebrew (OSX) | nerd.vision
This will show you all the versions of PHP available via brew, the “php” package represents the latest stable PHP version (which at the time of writing is 7.4) you can also see that versions 7.2 and 7.3 are available and I have them installed.
🌐
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.