1) Download and Install XAMPP
You can find the XAMPP installer on the following permalink:
https://www.apachefriends.org/index.html
2) Create a new project/folder
Go to the xampp\htdocs folder and create a new folder (with your project name)
3) Create a PHP file inside the project folder
Open vs code in the project folder and create a new PHP file with a .php extension (i.e FileName.php) with the following code

4) Open XAMPP Control Panel and start Apache server.
5) Open the browser and search localhost/FolderName/FileName.php
Congratulations you have successfully created and run your first PHP code using visual studio code๐.
You can also check my youtube video โhow to run PHP in Visual Studio Code in 2021โ if any doubt.๐



Top comments (2)
I have just moved to VS Code from Eclipse. Eclipse had a nice feature where you can connect a server to the XAMP/htdocs folder and it would sync to that folder which means that you can keep your source separate from the deployment folder. A nice feature would be to be able to run a script from within VS Code that did the deployment automatically.
Simple and precise explanation. Awesome.
I have a question though, would you prefer xampp rather than just install php, mysql and apache server manually.