Capstone: A Multi-File Profile Card Generator
Every chapter in this course introduced one piece in isolation. This capstone project pulls all of them together into a single small, working program: a profile card generator that takes a person's details from a simulated form submission and produces a formatted, styled summary — split across multiple files, the way a real project would be organised.
The Project Structure
The project is split into three files, each with a single clear job — mirroring the shared-header pattern from Chapter 9:
helpers.php— a small library of reusable functions (formatting, validation)profile_card.php— the function that builds a formatted profile card from a data arrayindex.php— reads the "submitted" data, includes the other two files, and renders the final output
Web Developer
Skills: PHP, MySQL, JavaScript
What Each Chapter Contributed
Nothing in the project above is new — every line traces back to a specific earlier chapter:
- Chapter 2 (Variables & Type Juggling):
$profile,$name,$skillList— variables holding and passing data between functions - Chapter 3 (Operators & Control Structures): the
ifcheck for a missing name, and the ternary? :deciding the skill list text - Chapter 5 (Functions & Scope):
formatName(),isValidField(), andbuildProfileCard()— each with its own local scope, parameters, and return value - Chapter 6 (Arrays):
$profileand$_POST['skills']as associative and indexed arrays, pluscount()andimplode() - Chapter 7 (Strings):
trim(),ucwords(),implode(), andsprintf()for building the final formatted output - Chapter 8 (Superglobals): reading
$_POSTsafely with the??null coalescing operator - Chapter 9 (Includes):
require_onceto pull the helper library and the card-builder function intoindex.php
index.php genuinely cannot build a profile card without buildProfileCard() being defined — if profile_card.php failed to load, the whole page should stop with a clear error rather than silently continuing and producing a confusing "call to undefined function" failure further down. That's exactly the require-over-include reasoning from Chapter 9, applied to a real project rather than an abstract rule.
Final Coding Challenge
Extend buildProfileCard() to also accept an optional "email" key. If present and valid (contains an @ character), append a line "Contact: {email}" to the output; if missing, append "Contact: not provided" instead. Test it with two different simulated $_POST arrays — one with a valid email, one without any email key at all — and echo both results.
📄 View solutionCourse Complete
This capstone closes out PHP Fundamentals. From here, PHP Intermediate builds directly on this foundation — sessions and cookies for remembering a visitor between page loads, object-oriented PHP (classes, the same concept the arrays and functions here were quietly building toward), working with a real MySQL database instead of simulated arrays, and proper input validation and sanitisation for handling real, untrusted user input safely.
Course 1 Complete — What You've Learned
- Ch 1–2: PHP syntax, echo, variables, and PHP's own type-juggling rules
- Ch 3–4: Operators, if/elseif/else, and all three loop types (for, while, foreach)
- Ch 5: Functions — parameters, return values, and global vs. local scope
- Ch 6: Indexed and associative arrays, plus the core array function library
- Ch 7: The string function library — searching, slicing, replacing, and sprintf formatting
- Ch 8: Reading external data safely via $_GET, $_POST, and $_SERVER
- Ch 9: Splitting code across files with include/require and their _once variants
- Capstone: a real multi-file project combining every one of the above