We already learned how to install and start the virtual server on a PC. Here we will check out how to write a simple Hello World program in PHP to display Hello World on the screen.
First of all, we will create a folder in the htdocs folder to save our PHP files. I am creating a folder named PHPTutorials. You can see it in the image given below.

In this PHPTutorials folder, we will create a file “HelloWorld.php”. It’s important to know that PHP files are saved using the .php extension.
Note! You can use any text editor to write PHP code like Notepad, Notepad++, Sublime Text. We will use here Sublime Text.
Basic PHP code Syntax:
To keep PHP code separate from HTML and CSS we have to write PHP code in Canonical PHP tags, which means we will write the whole PHP code inside these tags. Now we will see an example of the Hello World program.
<?php
echo "Hello World...";
?>
As you can see we have written our PHP code inside Canonical PHP tags which keep it separate from the rest of the code. we have used echo to show output on the screen which is Hello World. Now please save this file as HelloWorld.php in the PHPTutorials folder. After saving it we will run this code in the browser.
Note! Please make sure the Apache server is in start mode in your xampp software.
To run the code make sure your XAMPP server is on then type this localhost/PHPTutorials/HelloWorld.php chrome address URL bar and hit enter. You will see output like this.

Parvesh Sandila is a results-driven tech professional with 8+ years of experience in web and mobile development, leadership, and emerging technologies.
After completing his Master’s in Computer Applications (MCA), he began his journey as a programming mentor, guiding 100+ students and helping them build strong foundations in coding. In 2019, he founded Owlbuddy.com, a platform dedicated to providing free, high-quality programming tutorials for aspiring developers.
He then transitioned into a full-time programmer, where his hands-on expertise and problem-solving skills led him to grow into a Team Lead and Technical Project Manager, successfully delivering scalable web and mobile solutions. Today, he works with advanced technologies such as AI systems, RAG architectures, and modern digital solutions, while also collaborating through a strategic partnership with Technobae (UK) to build next-generation products.
