⚙️ Backend

PHP Fundamentals

Last updated: 2025-09-25 02:02:49

PHP Server-Side Programming

PHP is a popular server-side scripting language.

Basic Syntax

<?php
echo "Hello, World!";
?>

Variables and Data Types

$name = "John";
$age = 30;
$price = 99.99;
$isActive = true;
$colors = ["red", "green", "blue"];

Functions

function calculateArea($width, $height) {
    return $width * $height;
}

$area = calculateArea(10, 5);

Working with Forms

if ($_POST["submit"]) {
    $username = $_POST["username"];
    $email = $_POST["email"];
    // Process form data
}

File Operations

// Read file
$content = file_get_contents("file.txt");

// Write file
file_put_contents("file.txt", "Hello World");