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
- Go to File > Preferences > User Settings > Settings.json
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"
Relaunch VM Code

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:$PATHHit 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)
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
- Go to File > Preferences > User Settings > Settings.json
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"
Relaunch VM Code

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:$PATHHit 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)
To find out what version you're using, upload a php file to your server containing the following code...
<?php
phpinfo();
?>
It will tell you at the top of the page.
Videos
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.
If you have both versions of PHP installed, you can switch between versions using the link and unlink brew commands.
For example, to switch between PHP 7.4 and PHP 7.3
brew unlink [email protected]
brew link [email protected]
PS: Both versions of PHP have to be installed for these commands to work.
Example: Let us switch from php 7.4 to 7.3
brew unlink [email protected]
brew install [email protected]
brew link [email protected]
If you get Warning: [email protected] is keg-only and must be linked with --force
Then try with:
brew link [email protected] --force
Install php
brew install php@7.2
Install the required PHP to your PATH
echo 'export PATH="/usr/local/opt/php@7.2/bin:$PATH"' >> ~/.bash_profile
echo 'export PATH="/usr/local/opt/php@7.2/sbin:$PATH"' >> ~/.bash_profile
source ~/.bash_profile
Then make sure it's all working
php -v
php --version
This command will show you where your ini file is loaded
php --ini
Use Homebrew:
I would probably recommend installing homebrew to manage such installations for you. With that installed you can just run the following command to install php7.1
brew update
brew install php@71