How to run PHP in Visual Studio Code on Mac OS

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 the craze. Therefore today we’re going to show you How to run PHP in Visual Studio Code on Mac OS. Follow this tutorial step by step and you’ll be good to go.

 

Also Read: How To Install Command Line Developer Tools in Mac OS Big Sur

 

Video Tutorial: How to Run PHP in Visual Studio Code on Mac OS

 

No need to worry guys, currently we’re working on this tutorial, till then refer to the below article. If you have any Questions Feel Free To Ask.

 

Install PHP Extensions in Visual Studio Code on Mac OS

 

1) Open visual studio code, by pressing Cmd+space 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.

 

 

Run PHP in Visual Studio Code on Mac OS

 

1) Now create a new file in visual studio code and save it as  subscribe.php.

 

 

2) And paste the below-provided code snippet and press Cmd+S

 

<?php

echo "Subscribe Now!";

?>

 

 

3) To Run the PHP script press Cmd+Alt+N and you’ll see an output like the below image.

 

 

Fix Cannot Edit in reading Only Editor

 

1)  Now again create a new file in visual studio code and save it as an inputProgram.php

 

 

2) And paste the below-provided code snippet,  press Cmd+S and run the script by pressing Cmd+Alt+N

 

 

<?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 Cmd+, 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 Cmd+Alt+N this time it will show no errors.

 

Ethix

I'm a coding geek interested in cyberspace who loves to write and read

Leave a Reply

Your email address will not be published. Required fields are marked *