PHP tutorial

Build dynamic websites with server-side code

About this tutorial

PHP runs on the web server and builds pages before they reach the browser. It powers forms, logins and database-driven websites, including this portal.

In this beginner class you install a local server, learn variables, decisions, loops and functions, handle forms safely, remember visitors with sessions, and finally connect to a MySQL database to build a real project. Every lesson has examples, an exercise and a short quiz. Finish with the final quiz.

Lessons

Getting started

  1. Hello, PHPWhat PHP is, how to run it on your computer with XAMPP, and printing your first output with echo. Free 11 min
  2. Variables and arraysStore values in $variables, learn the main data types, join strings, and keep lists of values in arrays. Free 14 min
  3. Operators and stringsDo maths, compare values with == and ===, and use the most useful string functions. Locked 11 min

Making decisions and repeating

  1. If, else and matchMake your code choose what to do with if, elseif, else, the ternary operator and match. Locked 14 min
  2. LoopsRepeat work with for, while and foreach, and loop over arrays with keys and values. Locked 14 min

Functions and files

  1. FunctionsWrite reusable blocks of code with parameters, default values, return values and type hints. Locked 14 min
  2. Including files and page layoutsShare a header and footer across pages with require, and organise a small site into files. Locked 15 min

Working with the web

  1. Forms: GET and POSTReceive what visitors type with $_GET and $_POST, and learn when to use each method. Locked 21 min
  2. Validating and escaping inputNever trust what visitors type: check every field, show helpful errors, keep their answers, and escape output. Locked 16 min
  3. Sessions and cookiesRemember visitors from page to page with sessions, build a simple login flag and log out, and see when to use cookies. Locked 19 min
  4. Dates, JSON and filesFormat dates, work with DateTime, read and write files, and convert arrays to and from JSON. Locked 12 min

PHP and MySQL

  1. Connecting to MySQL with PDOCreate a database in phpMyAdmin and connect to it from PHP with PDO, handling errors properly. Locked 17 min
  2. Prepared statements: insert, update and deleteSave, change and remove data safely with prepared statements, and see why they stop SQL injection. Locked 20 min
  3. Project: a prayer request boardCombine forms, validation, sessions, PDO and escaping to build a small working web app. Locked 16 min
  4. PHP final quizFifteen questions covering the whole PHP beginner class. Score yourself to finish the course. Locked 6 min
Hi there! đź‘‹ Have a question about the courses or joining the class? Ask me.