Aral Code

Getting Started Lesson 1 of 17

Introduction to PHP

What PHP is, how server-side code differs from HTML and JavaScript, what PHP is used for, and what a first PHP page looks like.

PHP (a recursive name: "PHP: Hypertext Preprocessor") was created by Rasmus Lerdorf in 1994 to build his personal home page. It grew into one of the most widely used languages on the web. If a website has logins, forms that save data, or pages built from a database, there's a good chance PHP is involved.

Server-side vs client-side

HTML/CSS/JavaScriptPHP
Runs onThe visitor's browserThe web server
Visitor can see the code?Yes (View Source)No, only the result
Can use a database directly?NoYes
Good forLook and interactionLogins, saving data, building pages

When someone visits a .php page, the server runs the PHP code, which produces plain HTML. Only that HTML is sent to the browser.

Browser asks for grades.php  →  Server runs PHP (reads database)  →  sends HTML  →  Browser shows the page

Your first PHP page

<!DOCTYPE html>
<html>
<body>
  <h1>Welcome!</h1>
  <p>Today is <?php echo date("l, F j, Y"); ?>.</p>
  <p>2 + 3 = <?php echo 2 + 3; ?></p>
</body>
</html>

HTML sent to the browser

<!DOCTYPE html>
<html>
<body>
  <h1>Welcome!</h1>
  <p>Today is Wednesday, December 2, 2026.</p>
  <p>2 + 3 = 5</p>
</body>
</html>
  • PHP code goes between <?php and ?>.
  • echo outputs text into the page.
  • Everything outside the PHP tags is sent as-is.
  • Each PHP statement ends with a semicolon.

The browser never sees date(...); it only receives the finished date. That's why PHP can hide passwords and database details from visitors.

What is PHP used for?

  • Content management systems: WordPress, Joomla, Drupal.
  • Online shops: WooCommerce, Magento.
  • School and business systems: enrollment, grading, inventory and payroll systems, many of them built by local developers.
  • Frameworks: Laravel, one of the most popular web frameworks in any language.

Why learn PHP?

  • It's easy to start: XAMPP gives you a full server on your own computer for free.
  • Cheap web hosting almost always supports PHP and MySQL.
  • Many capstone and thesis projects (like reservation or inventory systems) use PHP and MySQL.
  • Freelance and job opportunities, especially WordPress and Laravel.

Quick Quiz

Check what you learned. Walang grade ito, practice lang. 🙂

1. Where does PHP code run?
2. Can a visitor see your PHP code with View Source?
3. Which tag starts PHP code?
4. Which statement outputs text in PHP?

By Sir Reyel · Last updated 2026-12-04