Introduction to PHP (ver 8.x): role of PHP in server-side web development; history and evolution; installation and configuration using XAMPP/WAMP; setting up the development environment using VS Code

PHP is the classic server-side language: it runs on the server, builds HTML, and sends the page to the browser, and this lesson sets up XAMPP so you can run your first .php file.

10 min read · 10 cards · 2 checks

Read in: English · हिन्दी · ગુજરાતી


Theory

Where your code runs matters

In BCA405-01 your JavaScript ran in the browser, on the student's phone. Then Node.js let JavaScript run on the SERVER instead. PHP is the language that made server-side web programming mainstream long before Node existed, and it still runs a huge share of the web.

This semester you will build a small event-registration portal with login in PHP. But PHP has one rule that trips up every beginner on day one: it runs on the SERVER, not in the browser, so you cannot just double-click a .php file and expect it to work. This lesson explains why, and gets you set up.

Theory

PHP, formally

PHP (PHP: Hypertext Preprocessor) is a widely used, open-source, server-side scripting language for web development.

The defining word is server-side: the web server runs your PHP code, which typically BUILDS HTML, and sends only the finished HTML to the browser. The browser never sees your PHP.

History in one line: created by Rasmus Lerdorf around 1994, it grew through PHP 5 and the much faster PHP 7 to today's PHP 8.x (with a JIT compiler, match expressions, named arguments and more). Its role: dynamic pages, form processing, and database-backed sites: exactly what an event portal needs.

Theory

The kitchen and the plate

Think of the browser as a diner and the server as a kitchen.

Client-side JavaScript is like garnishing the plate AT the table. Server-side PHP is the kitchen: the cooking happens out of sight, and only the finished dish (HTML) is carried out to the diner. The customer never sees the recipe, the raw ingredients, or the database the kitchen consulted. That hidden execution is why PHP can safely talk to databases and secrets: the browser only ever receives the plated result.

Practical

hello.php: PHP embedded in HTML

<!DOCTYPE html>
<html>
<body>
  <h1>Event Portal</h1>

  <?php
    // Everything between <?php and ?> runs on the SERVER
    echo "<p>Welcome! Server time is " . date("H:i") . "</p>";
  ?>

  <p>This line is plain HTML.</p>
</body>
</html>

Follow along

Setting up with XAMPP

  1. Install XAMPP (or WAMP) It bundles the Apache web server, PHP, and MySQL/MariaDB together: everything a PHP site needs in one install.
  2. Put your file in htdocs Save hello.php inside XAMPP's htdocs folder. This is the folder Apache serves from.
  3. Start Apache Open the XAMPP control panel and start Apache (and MySQL when you need the database).
  4. Open it through localhost Visit http://localhost/hello.php in a browser. Apache runs the PHP and returns HTML. Do NOT double-click the file.
  5. Edit in VS Code Use VS Code (with a PHP extension) as your editor; save, then refresh the browser to see changes.

Quiz

A student double-clicks hello.php to open it directly in the browser, and sees the raw PHP code as text instead of the page. Why?

  1. The PHP file is corrupted
  2. PHP is server-side: it must be run by a web server (Apache via XAMPP) and accessed through http://localhost, not opened as a file
  3. The browser needs a PHP plugin installed
  4. PHP only works in Chrome
Show the answer

PHP is server-side: it must be run by a web server (Apache via XAMPP) and accessed through http://localhost, not opened as a file

PHP executes on the SERVER, so the file must be served by Apache and reached via http://localhost/hello.php; opened directly as a file (file://), no server runs the PHP, so the browser just shows the source text. This is the number one day-one confusion. Option A is wrong (the file is fine). Option C is a myth: browsers do not run PHP at all, with or without a plugin: the server does. Option D invents a browser restriction. The fix is always: start Apache, access through localhost. Server-side means a server must be in the loop.

Think first

PHP or Node: same side, different language

In BCA405-01 you wrote a server in Node.js. Now PHP is also server-side. So what actually differs between them, and why might a project pick PHP? Then tap.

Show the answer

Both run on the SERVER and build responses for the browser, so they occupy the same ROLE. The difference is the language and ecosystem: Node runs JavaScript (one language across client and server) with an event-loop model, while PHP is a language built specifically for the web, traditionally paired with Apache and MySQL, and it powers enormous platforms like WordPress. A project might pick PHP for its maturity, huge hosting availability, gentle setup (XAMPP), and vast existing codebase. Neither is 'better': they are 2 answers to the same server-side question. Knowing both makes you flexible about where code should run.

Watch out

Setup traps

Double-clicking .php files: the quiz bug; always go through http://localhost.

Wrong folder: files outside htdocs are not served; Apache only sees htdocs.

Apache not started: localhost will not respond until Apache is running in the XAMPP panel.

Port conflicts: another program on port 80 can block Apache; XAMPP will flag it, and you can change the port.

Editing but not refreshing: PHP runs fresh on each request; save, then reload the browser.

Theory

The portal starts here

With XAMPP running and hello.php served, your development loop is set: write PHP, save, refresh localhost. Every lesson this unit adds a piece of the event portal: next comes the language's basic grammar (tags, echo, variables, comments), then data types, control flow and arrays, and form handling with $_GET and $_POST to actually process a registration. Server-side web development, one page at a time.

Summary

Key takeaways

  • PHP is a server-side scripting language: the server runs it and sends resulting HTML to the browser.
  • The browser never sees your PHP, only the finished output: which is why PHP can safely handle databases and secrets.
  • History: created by Rasmus Lerdorf (mid-1990s), evolved through PHP 5, 7, to today's PHP 8.x.
  • XAMPP/WAMP bundles Apache + PHP + MySQL; put files in htdocs and access via http://localhost.
  • You cannot double-click a .php file: it must be served by a running web server.
  • Same server-side ROLE as Node.js (BCA405-01), different language and ecosystem.
  • Memory hook: PHP is the kitchen; the browser only gets the plated dish.

Study this properly

This page is the lesson to read. In Gri-Learn the same topic is a graded deck: the self-checks are scored and your weak topics are tracked. Free to start.

Start this topic

Already have an account? Sign in

More from Core PHP Programming

Gri-Learn · syllabus-mapped B.C.A. lessons in English, Hindi and Gujarati

Introduction to PHP (ver 8.x): role of PHP in server-side web development; history and evolution; installation and configuration using XAMPP/WAMP; setting up the development environment using VS Code · Web Framework and Services (Major-12) · Gri-Learn