Capstone Project
This final chapter doesn't introduce new syntax — it's a small, complete project that uses every concept from Chapters 1 through 9 together, the way a real (if simple) PHP page actually gets built: split across files, validating form input, and formatting output.
What We're Building
A "Profile Card Generator" — a form where a visitor enters their name, age, and favourite colour. On submission, the page validates the input and displays a neatly formatted profile card, reusing a shared header/footer and a small library of helper functions.
Project Structure
functions.php — The Helper Library
Two pure functions: one returns an array of validation problems (Chapter 6's arrays + Chapter 3's conditions), the other builds the final display string (Chapter 7's string functions). Neither echoes anything directly — they hand results back via return (Chapter 5), which keeps them reusable and easy to test independently of any HTML.
header.php and footer.php
index.php — Tying It All Together
Notice every chapter's skill at work: $_SERVER/$_POST (Ch 8) drive the logic, ?? (Ch 3) guards against missing keys, the validation function returns an array (Ch 6) of problems, a foreach (Ch 4) displays them, and require/include (Ch 9) bring in the shared header/footer — with require chosen for the header (essential layout) and include for the footer (less critical), matching Chapter 9's guidance.
Coding Challenge — Extend the Capstone
Add a fourth field to the form: "hobbies", expecting a comma-separated list (e.g. "reading, chess, hiking"). In functions.php, write a new function that uses explode() and array_map() with trim() to turn it into a clean array, then use implode() to redisplay it as a tidy bulleted-feeling sentence in the profile card (e.g. "Hobbies: reading, chess, and hiking."). Wire it into index.php alongside the existing fields.
Course 1 Complete — PHP Fundamentals
- Chapters 1-9 covered: tags/echo, variables & types, operators & control flow, loops, functions & scope, arrays, strings, superglobals/forms, and includes
- This capstone combined all nine into one small, genuinely structured multi-file project
- Known, deliberate gap: no output escaping (htmlspecialchars) or database persistence yet — both covered in later courses
- Next: PHP Intermediate (Course 2) — object-oriented PHP, sessions, file handling, error handling, and database basics