'how to change the version of php in vscode?

I'm using iis and vscode to do php work. I recently updated iis from php7.3 to php7.4. My problem is that vscode is still using php7.3. I googled how to change the version in vscode and almost all the resources say that there's a JSON file that can changed under php settings in File > preferences > settings. When I search for php I'm not seeing any of these options. What am I doing wrong?

enter image description here

enter image description here



Solution 1:[1]

You can set the value directly as seen in your screenshot. Entry is named PHP Version. If you do so for that particular workspace, a file will be created at

{path_to_workspace}/.vscode/settings.json

If you don't see the folder .vscode in Explorer, you have to change the settings in Explorer to see hidden folders.

If you did set the PHP version on the page in your screenshot for that particular workspace then you should find in settings.json an entry that looks like the following

{
  "intelephense.environment.phpVersion": "8.1.0"
}

change that to

{
  "intelephense.environment.phpVersion": "7.4.0"
}

If you want to change the setting globally for all of your projects you can do the the following:

Open Explorer, or command line (cmd.exe) and type or copy the following line

%APPDATA%\Code\User\settings.json

Usually this will start vscode if not already running and open settings.json.

In that file at the beginning add after the opening bracket

  "intelephense.environment.phpVersion": "7.4.0",

  ... rest of the existing settings.json file here

Before you change these files manually, it might be a good idea to make a backup of these files.

Solution 2:[2]

While you can set the version for the intelephense addon, this won't help much because it appears that this setting doesn't apply to VSC itself. However you can set the php.validate.executablePath setting to the path to your php.exe file, for example "php.validate.executablePath": "C:/wamp64/bin/php/php7.4.9/php.exe". This should override a possibly wrong php path VSC takes from the system PATH env setting when php.validate.executablePath is not set.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Herbert Peters
Solution 2 Charon ME