Introduction to PHP – What is PHP & How It Works
In this lesson: What PHP is, why it powers most websites, how it runs on the server and your first Hello World script — simple Hindi & English.
What is PHP
PHP is a popular server-side language for building websites. When you log in somewhere, submit a form, or see a page that changes for each user, a language like PHP is usually doing that work on the server. PHP originally stood for "Personal Home Page", and today it powers a huge part of the web, including WordPress.
<?php ... ?> tags and can be mixed right into an HTML file.Server-side, not browser
This is the most important idea for a beginner. PHP runs on the server, not in the visitor's browser. The server runs your PHP, builds a plain HTML page as the result, and only that HTML is sent to the browser. The visitor never sees your PHP code.
This is why PHP can safely do things like check passwords or read a database — that logic stays on the server, hidden from users.
Why PHP is popular
- Easy to start. You can mix PHP into HTML and see results quickly.
- Runs almost everywhere. Nearly every web host supports PHP.
- Works great with MySQL. The PHP + MySQL combo is the classic way to build data-driven sites.
- Huge community. Tons of tutorials, free code and ready libraries.
Your first PHP page
Here is the classic first program.
<?php
echo "Hello, World!";
?>
The <?php opens PHP, echo outputs text, and ?> closes it. Save this as hello.php and open it through a server to see the result.
How a PHP request works
- The visitor's browser asks for a
.phppage. - The server runs the PHP code in that file.
- The PHP produces plain HTML as its output.
- The server sends that HTML back to the browser.
- The browser shows the page — with no PHP visible.
So PHP is like a chef in the kitchen: the customer only gets the finished dish (HTML), never the recipe (your PHP code).
Common mistakes
- Opening a .php file directly. Double-clicking shows the code; you must open it through a server (like XAMPP).
- Wrong file extension. Save as
.php, not.html, or the code will not run. - Forgetting the closing
?>. In mixed files, always close your PHP block properly. - Expecting PHP to change a page after it loads. PHP runs once on the server; live browser changes need JavaScript.
Summary
- PHP is a server-side language for building dynamic websites.
- It runs on the server and sends plain HTML to the browser.
- Code goes inside
<?php ... ?>and can mix with HTML. - PHP pairs naturally with MySQL for data-driven sites.
- Run
.phpfiles through a server like XAMPP, not by double-clicking.
Next, set up your environment with XAMPP setup, or learn the basics of writing code in PHP syntax.
Frequently Asked Questions
What is PHP in simple words?
Is PHP still worth learning?
What is the difference between PHP and HTML?
Do I need to install anything to run PHP?
What does the .php file extension mean?
.php tells the server to run the PHP code inside it before sending the result. A plain .html file is sent as-is without any server processing.