Skip to content
Home Tutorials Roadmaps Courses
Log in Join free
Tutorials PHP Introduction to PHP
PHP Intermediate FREE

Introduction to PHP

Lesson 1 of 17 Intermediate Interactive

PHP stands for PHP: Hypertext Preprocessor. It is a powerful, server-side scripting language designed for web development. PHP runs on the server and generates HTML that is sent to the user's browser.

What is PHP?

  • A server-side scripting language (code runs on the server, not in the browser)
  • Powers over 78% of websites including WordPress, Facebook, Wikipedia, and Slack
  • Excellent for building dynamic web pages, APIs, and database-driven applications
  • Works seamlessly with MySQL, PostgreSQL, and other databases

Why Learn PHP?

  • Easy to learn — Beginner-friendly syntax
  • Huge ecosystem — Laravel, Symfony, WordPress, and thousands of packages
  • Job market — High demand for PHP developers worldwide
  • Free and open source — No licensing costs
  • Great documentation — Extensive official PHP manual

How PHP Code Runs

When a user requests a PHP file, the web server passes the file to the PHP interpreter. The PHP code is executed, and the output (usually HTML) is sent back to the user's browser. The browser never sees the raw PHP code — only the final HTML output.

Syntax

PHP
<?php
// PHP code is enclosed in <?php ... ?> tags

echo "Hello, World!";

// Variables start with $

$name = "Sukhwinder";
$age = 25;

echo "My name is $name and I am $age years old.";
?>
Hello World in PHP
PHP
<?php
echo "Hello, World!
";
echo "PHP runs on the server
";

$name = "SukhNexus Academy";
echo "Welcome to " . $name . "
";

// Variables
$age = 25;
$price = 19.99;
$isActive = true;
echo "Age: $age, Price: $price
";
?>

Practice

1
Exercise

Create a PHP variable called $course and echo "I am learning [course name]".

Answer
<?php
$course = "PHP";
echo "I am learning $course!";
?>
2
Exercise

Use echo to display an HTML heading with your name.

Answer
<?php
echo "<h1>My name is Sukhwinder</h1>";
?>

Quick Quiz

1

Where does PHP code execute?

PHP code runs on the server, and only the output (usually HTML) is sent to the browser.

2

What does PHP stand for?

PHP originally stood for Personal Home Page but now stands for PHP: Hypertext Preprocessor (a recursive acronym).

3

How do you start a PHP code block?

PHP code blocks start with <?php and end with ?>.

Interview Questions

PHP runs on the server (server-side) and is great for database operations, file handling, and form processing. JavaScript runs in the browser (client-side) and is used for interactivity and UI updates. They complement each other well in web development.

When a browser requests a .php file, the web server passes the file to the PHP interpreter. PHP executes the code, generates output (typically HTML), and sends it back to the browser. The browser then renders the HTML. The user never sees the raw PHP source code.