How to let my php code work in the browser?

I just started learning php and thought it would be just like html,but when I created a file called test.php and wrote the following code inside:

<!DOCTYPE html>

echo "<p>hello</p>";


then save the file to desktop.Its icon wasn’t google chrome(my default browser) like .html files but something looked like a sheet of paper,so I’ve no idea how to open it in the browser to see the results like I do with .html files.
Is there something wrong with my file name?Or is there anything I should download first?Or anything else?

PHP runs on a server, a program on the server takes that PHP file and turns it into HTML, browsers cannot read PHP files.

You need a web server that can run PHP, and normally you’d want a database as well, XAMMP lets you setup a full environment to develop in

thanks DanCouper!It works now!

1 Like