Looks like you in fact don't want to run PHP from Visual Code, but instead you're trying to get PHP to work at all.

  1. add in external php file which I created now

You're using short tags and that's ok, if your configuration allows it, however I would recommend using explicit PHP tags: <?php echo "My First PHP site in VSCode."; ?>

In my index.html file I referenced my php file like:

There's the problem. You're placing PHP code in a HTML file. PHP code in HTML files won't be (at least by default) executed. Change the filename from index.html to index.php.

That should do it.

Answer from Smuuf on Stack Overflow
🌐
Microsoft Learn
learn.microsoft.com › en-us › answers › questions › 908531 › how-to-customize-visual-studio-to-php-development
How to customize Visual Studio to php development? - Microsoft Q&A
Install Google Chrome Live Server extensions. (https://chrome.google.com/webstore/detail/live-server-web-extension/fiegdmejfepffgpnejdinekhfieaogmj) Open your PHP file in Visual Studio Code and 'Click to run Live Server'.
🌐
Visual Studio Code
code.visualstudio.com › docs › languages › php
PHP in Visual Studio Code
November 3, 2021 - To set the PHP executable path, select the Edit in settings.json link under PHP > Validate: Executable Path, which will open your user settings.json file. Add the php.validate.executablePath Open in VS Code Open in VS Code Insiders setting with the path to your PHP installation: { "php.validate.executablePath": "c:/php/php.exe" } { "php.validate.executablePath": "/usr/bin/php" } or { "php.validate.executablePath": "/usr/local/bin/php" } Visual Studio Code includes a set of common snippets for PHP.
🌐
PHP Freaks
forums.phpfreaks.com › other › editor help (phpstorm, vs code, etc)
VS Code - Open PHP in Browser Extension - Editor Help (PhpStorm, VS Code, etc) - PHP Freaks
October 18, 2022 - Version: 1.71.2 (user setup) Commit: 74b1f979648cc44d385a2286793c226e611f59e7 Date: 2022-09-14T21:03:37.738Z Electron: 19.0.12 Chromium: 102.0.5005.167 Node.js: 16.14.2 V8: 10.2.154.15-electron.0 OS: Windows_NT x64 10.0.22622 Sandboxed: No Visual Studio Code on Windows 11. Greetings. I tend to ha...
🌐
Reddit
reddit.com › r/vscode › how to see php output in the browser?
r/vscode on Reddit: How to see PHP output in the browser?
August 27, 2023 -

I'm new to all of this (PHP, VS Code & remote debugging) but I've managed to connect to my remote server with VS Code and I am trying to learn PHP coding while I learn VS Code.

I opened the most simple file I could think of....

 <?php
phpinfo();

And I wanted to try just adding a breakpoint and stepping through the one line of code (baby steps).

It works fine. It shows text results in the Debug Console window, but I thought I'd see the output in a browser window somewhere.

I'd like to be able to see the output of the PHP code I am planning to write in the browser. Is that possible?

🌐
YouTube
youtube.com › watch
How to Run PHP in VS Code | Visual Studio Code | - YouTube
How to Run PHP File in VS Code | Visual Studio Code |php server https://tubemint.comhttps://nichehow.com
Published   June 7, 2021
🌐
YouTube
youtube.com › watch
How to Run PHP on VSCODE | How to Run PHP Code on Chrome | PHP Code Not Running in xampp - YouTube
How to Run PHP on VSCODE | How to Run PHP Code on Chrome | PHP Code Not Running in xampp #xamppserver #phpcode #vscode #localhost #phpscripts In this video...
Published   July 25, 2022
🌐
Brainly
brainly.com › computers and technology › high school
how to open php file in browser vscode? - brainly.com
To open a PHP file in a browser through VSCode, install a local server like XAMPP, place PHP files in the 'htdocs' or 'www' directory, start the server, and then navigate to the localhost URL of your file in the browser.
Find elsewhere
🌐
YouTube
youtube.com › amit thinks
How to run PHP on Visual Studio Code - YouTube
Learn how to run a PHP program on Visual Studio Code. You need XAMPP as well for server with VS Code. Install XAMPP on Windows 10 https://youtu.be/Jd4H-4zfRw...
Published   October 12, 2020
Views   374
🌐
YouTube
youtube.com › watch
How to run php file in visual studio code with xampp - YouTube
How to run php file in visual studio code, How to make php build task in visual studio code problem solved,how to run php code in visual studio code or vscod...
Published   August 9, 2017
🌐
DEV Community
dev.to › itsmestevieg › vscode-liveserver-for-php-2i3m
VSCode: LiveServer for PHP - DEV Community
October 4, 2023 - Create a PHP file, for instance, ... your Chrome browser and customize it as follows: Click on the 'Go Live' button in the bottom right hand corner of the Visual Studio Code....
🌐
DEV Community
dev.to › sainathpoojary › how-to-run-php-in-visual-studio-code-in-2021-hec
How to run PHP in Visual Studio Code in 2021? - DEV Community
March 28, 2021 - 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 · Congratulations you have successfully created and run your first PHP code using visual studio code🎉.
🌐
WPWeb Infotech
wpwebinfotech.com › wpweb infotech › blog › php › run php in visual studio code: easy setup & debugging tips
How To Run PHP In Visual Studio Code?
December 30, 2025 - Through this guide, you’ll learn how to set up Visual Studio Code for PHP development. Plus, you’ll see how to create a PHP file and run it in VSC.
🌐
Reddit
reddit.com › r/vscode › is there a "simple" way of running php soely through visual studio code?
r/vscode on Reddit: Is There A "simple" way of running PHP soely through Visual Studio Code?
April 1, 2024 -

So I've been using XAAMP to run PHP on my laptop and it works as it should. But it requires me to use a URL and then find the projects within the htdocs folder. I was wondering if there was something like Live Server that I could activate from Visual Studio and have it appear in the Web Browser.

I've done google searches on this already and it led me to download php extensions like php server and the php debugger extension.

However, I am a bit confused by these and what they do and I'm not sure if this is supposed to perform in a similar way that live server performs.

I've ran into issues though in getting VS Code to use the correct environmental variable. It keeps throwing an error that says the binaries couldn't be found or executed even though I have the path set in the json file to the folder holding the PHP related code.

I'm a bit confused and I'm also curious about whether or not what I'm trying to do is achievable or not.

🌐
Alphr
alphr.com › home › how to open in browser from vs code
How to Open in Browser from VS Code
June 10, 2022 - If you’re using HTML, PHP, or JS files, you might want to open them in your browser from Visual Studio Code. However, there’s no integrated option to do
🌐
Quora
quora.com › How-do-you-run-a-PHP-script-from-within-Visual-Studio-Code-VS-code-without-debugging-it
How to run a PHP script from within Visual Studio Code (VS code) without debugging it - Quora
Answer: There is a much easier ... 2. Open the PHP code file in Text Editoruse shortcut [code ]Ctrl+Alt+N[/code]or press [code ]F1[/code] and then select/type [code ]Run Code[/code],or right click the Text Editor and then ...