agyanadda@gmail.com

PHP Introduction

PHP Basics 1 min read Updated Dec 1, 2026 Topic 1 of 36

PHP (PHP: Hypertext Preprocessor) is a server-side scripting language. PHP code runs on the web server, and the browser receives only the resulting HTML.

How PHP works

  1. The visitor opens index.php
  2. The server runs the PHP code (reads the database, checks login, etc.)
  3. The server sends plain HTML back to the browser

That is why visitors can never see your PHP code — only its output.

What can PHP do?

  • Create dynamic pages ("Welcome, Asha")
  • Handle forms: contact, login, registration
  • Read and write a MySQL database
  • Manage sessions and cookies
  • Upload files, send emails, generate PDFs
  • Build REST APIs that return JSON

Why learn PHP?

  • Powers WordPress, Laravel, Facebook (originally), Wikipedia
  • Runs on almost every cheap hosting plan
  • Easy to start, with huge job demand in India for PHP/Laravel developers

You should know basic HTML before starting. This tutorial uses PHP 8.

Example

Example — Your first PHP page PHP
<!DOCTYPE html>
<html>
<body>
  <h1><?php echo 'Hello from PHP!'; ?></h1>
  <p>Today is <?php echo date('l, d F Y'); ?>.</p>
</body>
</html>

Output in the browser: a heading "Hello from PHP!" and today's date, e.g. "Today is Tuesday, 01 December 2026." View the page source — you will see only HTML, no PHP.

Test Yourself With Exercises

Exercise 1 Multiple Choice

Where does PHP code run?

Exercise 2 True / False

Visitors can see your PHP source code with View Source.

Exercise 3 Fill in the Blank

PHP files are saved with the .___ extension.

Frequently Asked Questions

Yes. PHP runs a large share of the web, including WordPress, and Laravel is one of the most popular backend frameworks. PHP developers are in steady demand.