Free tutorials & notes in Hindi & English · Clean code examples 🧰 Free PDF & Image Tools →
🟢 Foundation  ·  Lesson 01

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 code is written inside <?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!";
?>
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

  1. The visitor's browser asks for a .php page.
  2. The server runs the PHP code in that file.
  3. The PHP produces plain HTML as its output.
  4. The server sends that HTML back to the browser.
  5. 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 .php files 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?
PHP is a server-side scripting language used to build websites. It runs on the web server, creates the HTML page, and sends the finished page to the visitor's browser. Most dynamic websites — logins, forms, dashboards — use a language like PHP behind the scenes.
Is PHP still worth learning?
Yes. A very large share of the web runs on PHP, including WordPress. It is beginner-friendly, has huge community support, and is in demand for web development jobs, so it remains a practical first backend language.
What is the difference between PHP and HTML?
HTML describes the structure of a page and runs in the browser. PHP runs on the server and can create or change HTML before the page is sent. HTML is static; PHP makes pages dynamic.
Do I need to install anything to run PHP?
To run PHP on your own computer you install a local server like XAMPP, which includes PHP, Apache and MySQL. Then you place your .php files in its web folder and open them through the local server.
What does the .php file extension mean?
A file ending in .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.
← Back to PHP Tutorial
🔗

Share this topic with a friend

यह topic किसी दोस्त को भेजें

Found it useful? Send it to a classmate learning the same thing.

अच्छा लगा? जो दोस्त यही सीख रहा है, उसे भेज दीजिए।

💻 Live Code Editor

This page's programs are ready here — run them, edit them, and learn. No installation needed.
Powered by OneCompiler. The code loads into the editor automatically — press Run to see the output. If the editor does not open, open it in a new tab.
Next topicPHP Setup with XAMPP Your progress: 1 / 50 (2%) · Lesson 2 / 50 Continue →

How was this lesson?

Your feedback helps us make the content better.

Write a review or suggestion (optional)

After approval, your name and city may appear publicly with your review. Please do not write your email or phone number.

▶ CodingEasily on YouTube

Learn with video lessons in easy Hindi

Featured video: RDBMS Part 3 – Class XI Commerce IT

▶ Subscribe – it’s free