15-Day PHP Learning Worksheet

Day 1: Introduction to PHP & Environment Setup

Theory (2 Hours):
Practical (4 Hours):
<?php
echo "Hello, PHP World!";
?>

Day 2: PHP Syntax, Variables & Data Types

Theory (2 Hours):
Practical (4 Hours):
<?php
$name = "Aquila";
$age = 25;
$price = 99.99;
$isAvailable = true;
echo "Welcome $name. Age: $age - Price: ₹$price";
?>

Day 3: Operators and Control Statements

Theory:
Practice:
<?php
$score = 80;
if($score >= 90) echo "Grade A";
elseif($score >= 75) echo "Grade B";
else echo "Try Again!";
?>

Day 4: Loops in PHP

Theory:
Practice:
<?php
for($i = 1; $i <= 5; $i++) {
  echo "Number $i <br>";
}
?>

Day 5: Functions & Arrays

Theory:
Practice:
<?php
function greet($name) {
  return "Hello $name!";
}
echo greet("Aquila");
$colors = ["red", "green", "blue"];
echo $colors[1];
?>

Day 6: Forms & User Input

Theory:
Practice:
<form method="post">
  Name: <input type="text" name="username">
  <input type="submit">
</form>

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
  echo "Hello " . htmlspecialchars($_POST['username']);
}
?>

Day 7: PHP File Handling

Theory:
Practice:
<?php
$file = fopen("data.txt", "w");
fwrite($file, "Learning PHP");
fclose($file);
?>

Day 8: Sessions and Cookies

Theory:
Practice:
<?php
session_start();
$_SESSION['user'] = "Aquila";
echo "Session user is: " . $_SESSION['user'];
?>

Day 9: Connecting to MySQL

Theory:
Practice:
<?php
$pdo = new PDO("mysql:host=localhost;dbname=testdb", "root", "");
$stmt = $pdo->query("SELECT * FROM users");
while ($row = $stmt->fetch()) {
  echo $row['name'] . "<br>";
}
?>

Day 10: Inserting & Retrieving Data

Theory:
Practice:
<form method="post">
  Name: <input type="text" name="name">
  <input type="submit">
</form>

<?php
$pdo = new PDO("mysql:host=localhost;dbname=testdb", "root", "");
if ($_POST) {
  $stmt = $pdo->prepare("INSERT INTO users (name) VALUES (?)");
  $stmt->execute([$_POST['name']]);
  echo "Inserted!";
}
?>

Day 11: Update & Delete Operations

Theory & Practice:
<?php
$pdo = new PDO("mysql:host=localhost;dbname=testdb", "root", "");
$stmt = $pdo->prepare("UPDATE users SET name = ? WHERE id = ?");
$stmt->execute(["NewName", 1]);
?>

Day 12: Basic CRUD Application

Build:

Day 13: Introduction to AJAX in PHP

Use:

Day 14: PHP & JSON

Concepts:

Day 15: Mini Project - User System

Project: