If you’re into web development then it’s likely that you will need to learn PHP to develop the back-end database of your website. And nowadays web development is going in a craze. Therefore today we’re going to show you How to run PHP in Visual Studio Code on Windows 11. Follow this tutorial step by step and you’ll be good to go.
Video Tutorial: How to Run PHP in Visual Studio Code on Windows 11
Step 1:Download PHP For Windows 11
1) Firstly we will download the latest version of PHP available on the internet. Follow the below-provided link to download PHP for window 11. There simply click on the
Zip button under
PHP 8.0(8.0.9) section.
Download PHP Here: https://windows.php.net/download/
Step 2: Extract Zip File
1) Open up the folder where the downloaded
.zip file is available, right-click on the file and click on the
Extract All button.
2) In the extraction window click on the
3) And create a
New Folder with the name
PHP8. After that click on the
Select Folder button.
4) Now in the extraction window simply click on the
Also Read: How to Install Android Studio on Windows 10
Step 3: Set Up Environment Variables
1) Press Windows button, type Environment Variables and hit Enter.
2) Now click on the
Environment Variable button.
3) Now, select the
Path variable by simply clicking on it and after that click on the
4) Now click on the
New button and paste the location we’ve provided below in this blank field and click the
Step 4: Check PHP VERSION
1) To check if PHP is working properly or not, open up your command prompt by pressing the Windows button, type
cmd and press enter.
2) In the command prompt type,
PHP --version and press enter to check the installed version of PHP.
Step 5: Install PHP Extensions in Visual Studio Code on Windows 11
1) Open visual studio code, by pressing Windows type
Visual Studio Code and press enter.
2) Click on the extension button and in the search bar type
PHP Debug, select the first option from Felix Becker and click on the small blue install button.
3) Again in the search bar type
Code Runner, select the first option from Jun Han and click on the install button.
Step 6: Run PHP in Visual Studio Code on Windows 11
1) Now create a new file in visual studio code and save it as
2) And paste the below-provided code snippet and press
<?php echo "Subscribe Now!"; ?>
3) To Run the PHP script press
Ctrl+Alt+N and you’ll see an output like the below image.
Step 7 [Bonus]: Fix Cannot Edit in reading Only Editor
1) Now again create a new file in visual studio code and save it as an
2) And paste the below-provided code snippet, press
Ctrl+S and run the script by pressing
<?php $firstName = readline("Enter your first name : "); $lastName = readline("Enter your last name: "); echo "Your Full Name is ".$firstName." ".$lastName; ?>
3) For the first time you will face an error like the below image.
4) Open up settings by pressing
Ctrl+, In the search bar type
Run In Terminal and hit enter. Scroll down and tick the
Code Runner: Run in Terminal checkbox.
5) Now go back to the program we’ve created at step 2 and press
Ctrl+Alt+N this time it will show no errors.