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.
- 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 OverflowLooks 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.
- 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.
For running simple php website below are the two short steps
1. In VS code install PHP debug extension
2. From terminal run the command
php -S localhost:8080
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?
Debugging PHP with VSCode using the vscode-php-debug extension
VSCode can now support debugging PHP projects through the marketplace extension vscode-php-debug.
This extension uses XDebug in the background, and allows you to use breakpoints, watches, stack traces and the like:

Installation is straightforward from within VSCode: Summon the command line with F1 and then type ext install php-debug
As far as I read about it today, you can't debug anything else than node.js, JavaScript and TypeScript at the moment, but they said they want to add new languages which you can debug. The editor is still in development. Nevertheless, I don't think there will be a php debugger in the future since php is serverside, so you can't debug it on your client alone.
If you want to debug php, I can recommend xDebug.
Updated:
Now, it is possible to debug with VS code. You need to install XDebug and php-debug extension for VScode.
Hi, I am a PHP beginner. I use VS code and Chrome browser for development environment. Is there any extension to see PHP code as live view in Chrome browser? Thanks.
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.