PHP · Beginner
PHP Fundamentals
Learn server-side programming with PHP: variables, control flow, functions, forms and the basics of keeping user data safe.
- Units
- 4
- Lessons
- 20
- Practice questions
- 58
- Minutes
- ~300

Start learning today
Try every course free for 7 days. After that, this course is in Learnix Pro (KES 699/month).
Create free account Log inWhat you'll learn
Write and run basic PHP scripts
Use variables, arrays and control structures
Build functions and reusable logic
Handle form submissions safely
Understand sessions and basic security practices
How the lessons work
Clear explanations
Step-by-step lessons in plain language
54 in this course
Worked examples
Real code and examples you can copy and run
78 in this course
Quick checks
Test your understanding as you go
38 in this course
Fill the blank
Recall the key commands and syntax
20 in this course
Hands-on workspace
A practical task at the end of every lesson
20 in this course
Syllabus
-
1.1
PHP Introduction
PHP does its work on the server, behind the scenes, before any HTML ever reaches the visitor's browser: it's the difference between a static page and one that can actually think.
-
1.2
Variables & Data Types
A PHP variable is a labeled box you can put a value into: it always starts with $, and PHP figures out what kind of value is inside without you ever having to say so.
-
1.3
Control Structures
if/else lets your code make decisions, and for/while/foreach let it repeat itself: the two ingredients almost every useful program is built from.
-
1.4
Functions & Arrays
A function lets you name a set of steps once and reuse it forever after; an array lets you hold many related values under a single name instead of juggling separate variables.
-
1.5
Array Functions in Depth: map, filter, sort & more
PHP has over 70 array functions. Learn the dozen you will use every week to transform, filter, sort and summarise data without writing long loops.
-
2.1
Working with Forms ($_GET and $_POST)
When a form is submitted, PHP automatically hands you the submitted values in a superglobal array, and every single value that comes from a visitor has to be treated as untrusted until proven otherwise.
-
2.2
Sessions, Cookies & Security Basics
The web forgets everything between page loads by default: sessions are how PHP gives each visitor a bit of memory, and a few simple habits now will save you from the most common beginner security mistakes later.
-
2.3
Web Security Essentials: XSS, CSRF, SQL Injection & Passwords
The four mistakes behind most hacked PHP sites, and the simple habits that prevent them.
-
2.4
String Functions in Depth
PHP ships with a huge library of ready-made functions for slicing, searching, and reshaping text: knowing a handful of common ones well will save you from writing character-by-character loops for problems PHP has already solved.
-
2.5
Working with Dates and Times
PHP has both a quick, function-based way to work with dates (date()) and a fuller object-oriented one (DateTime): knowing when to reach for each will save you a lot of headaches once your app needs to handle real calendar dates.
-
3.1
Object-Oriented PHP Basics
A class is a blueprint, an object is one thing built from it: bundling related data and the functions that act on it together, instead of keeping them as separate loose variables and functions.
-
3.2
Interfaces, Inheritance, Traits & Namespaces
Go beyond single classes: share behaviour with inheritance and traits, define contracts with interfaces, and organise code into namespaces.
-
3.3
Modern PHP 8: match, Enums, Readonly & Named Arguments
PHP 8 made the language safer and much more pleasant. Learn the features you will see in every new codebase.
-
3.4
Composer, Packages & Autoloading
Stop copying code from the internet. Install tested packages with Composer and load your own classes automatically.
-
3.5
Error Handling with Try/Catch
Not every problem in a program can be prevented in advance: try/catch lets your script notice when something goes wrong at runtime and respond deliberately, instead of crashing outright or failing silently.
-
4.1
Reading and Writing Files
Sometimes data needs to live in a plain file on disk rather than a database: PHP's file functions let you read, write, and append to files, though a few small habits keep this power from causing quiet data loss.
-
4.2
Connecting to MySQL with PDO
Connect PHP to a MySQL database safely with PDO, run queries with prepared statements, and fetch rows as arrays.
-
4.3
Build a Complete CRUD App
Create, Read, Update and Delete: the four operations behind almost every admin panel. Build a small contacts manager from scratch.
-
4.4
JSON APIs: Build One and Call One
Return JSON from PHP so apps can use your data, and call other APIs (like a currency or M-Pesa API) with cURL.
-
4.5
Final Project: A Mini Booking System
Plan and build a small booking system for a salon or clinic, combining forms, validation, sessions, PDO, security and JSON.
Earn a verifiable certificate
Finish every lesson and pass the 20-question final exam (70% to pass). Each certificate has a unique number anyone can check online.