Course

PHP from the ground up

The language behind the web page

  • Beginner
  • 13 chapters
  • 201 min read

Learn PHP by running it: variables and types, strings, numbers and money, decisions and the equality trap, loops, arrays and their functions, your own functions, classes, inheritance and interfaces, errors and validation, and an expense report that uses the whole course at once.

What You'll Learn

  • Write and run a PHP script, and know what the opening tag does
  • Hold values in variables, and inspect types instead of guessing
  • Clean up, join and format text with the everyday string functions
  • Do arithmetic that adds up, including division, remainders and money
  • Branch with if, ternary and match — and compare with === as the default
  • Repeat work with for and while, and leave a loop early on purpose
  • Use arrays as lists and as keyed records, and loop with foreach
  • Replace whole classes of loops with map, filter, reduce and sort
  • Write typed functions with defaults and return types, under strict mode
  • Build classes with constructors, methods and visibility
  • Extend a class and implement an interface, and use polymorphism
  • Validate at the edge, throw with a reason, and catch what you can handle
  • Assemble a typed expense report with classes, functions and array functions

Prerequisites

  • No programming experience needed — this course starts at the first line
  • Comfort with a web page (HTML) helps you see where PHP output goes

Course Content

  1. 01
    Your first PHP script

    The opening tag that makes a file PHP, echo as the way to say something, and the dot that joins pieces of text together.

    Beginner · 12 min read

    Not started
  2. 02
    Variables and types

    The dollar sign, the eight kinds of value PHP has, looking at a value's type instead of guessing, and converting between them on purpose.

    Beginner · 14 min read

    Not started
  3. 03
    Strings that do work

    Single and double quotes and what each does with $, interpolation, and the handful of string functions that turn raw text into something presentable.

    Beginner · 14 min read

    Not started
  4. 04
    Numbers and money

    Integer and float arithmetic, division that stays whole, powers and rounding, and the function that turns a raw number into money people can read.

    Beginner · 14 min read

    Not started
  5. 05
    Decisions: if, and the equality trap

    Branching with if and elseif, choosing between two values with a ternary, the match expression, and the one comparison rule that saves the most debugging time.

    Beginner · 15 min read

    Not started
  6. 06
    Loops

    Repeating work a known number of times with for, an unknown number with while, and the two statements that skip an iteration or leave the loop early.

    Beginner · 14 min read

    Not started
  7. 07
    Arrays: lists and lookup tables

    One type, two habits — a numbered list and a keyed table — plus count, foreach, and the difference between an array and a fact.

    Beginner · 16 min read

    Not started
  8. 08
    Array functions instead of loops

    Map, filter and sort: the operations that loops were doing, said by name — and the arrow functions that describe each one in a line.

    Intermediate · 16 min read

    Not started
  9. 09
    Functions of your own

    Naming a piece of work once, parameters and their defaults, return types, and the strict mode that turns quiet conversions into loud mistakes.

    Intermediate · 16 min read

    Not started
  10. 10
    Classes: your own types

    Bundling data with the functions that work on it: properties, a constructor, methods, $this, and the visibility keywords that keep the inside inside.

    Advanced · 17 min read

    Not started
  11. 11
    Inheritance and interfaces

    Extending a class to change part of it, an interface as a promise several classes can keep, and the polymorphism that lets one function accept all of them.

    Advanced · 17 min read

    Not started
  12. 12
    Errors, and checking what arrives

    Throw when a value cannot be used, catch where something can be done about it, and validate at the edge so the inside of the program only ever sees good data.

    Advanced · 16 min read

    Not started
  13. 13
    Putting it together: an expense report

    A capstone that uses the whole course once: a class for the records, functions for the work, array functions for the questions, formatting for the report.

    Advanced · 20 min read

    Not started