"I am Saqib Jahangir. A passionate vlogger, software engineer, trainer and avid traveler with a deep love for exploring the hidden gems of our beautiful planet. With a strong foundation in Application Development, Application Architecture & Database Design and Product Management, I bring over a decade of hands-on experience building secure, scalable, and resilient web applications for a diverse range of industries."

What is PHP?

 1. Introduction

PHP (Hypertext Preprocessor) is an open-source, server-side scripting language used primarily for web development. It is embedded into HTML and executed on the server, meaning the client only receives the final output (HTML, JSON, etc.), not the actual PHP code.


2. Key Features of PHP

  • Server-Side Execution – Code runs on the server before being sent to the browser.
  • Open Source – Free to use with a large community of developers.
  • Cross-Platform – Works on Windows, Linux, and macOS.
  • Database Support – Works with MySQL, PostgreSQL, SQLite, and more.
  • Easy Integration – Can be embedded inside HTML or used with popular frameworks like Laravel, Symfony, and CodeIgniter.

3. Basic PHP Syntax

A PHP script starts with <?php and ends with ?>.

<?php

echo "Hello, World!";

?>

When executed, the browser displays:

Hello, World!


4. PHP in Action

PHP can:

  • Process form data
  • Generate dynamic page content
  • Manage sessions and cookies
  • Communicate with databases
  • Build REST APIs

Example: Simple PHP form handling

<?php

if ($_SERVER["REQUEST_METHOD"] == "POST") {

    $name = htmlspecialchars($_POST['name']);

    echo "Hello, " . $name;

}

?>

<form method="post">

    <input type="text" name="name" placeholder="Enter your name">

    <button type="submit">Submit</button>

</form>

 

Popular Posts

Operators (Arithmetic, Comparison, Logical)

Functions (Built-in & User-defined)