PHP Fundamentals
Learn server-side programming with PHP — variables, control flow, functions, forms and the basics of keeping user data safe.
1
units
11
lessons
22
practice questions
~165
minutes
Start learning today
Create a free account, then unlock this and every other Pro course with Learnix Pro for KES 999/month.
Create free account I already have an accountOutcomes
What you'll be able to do
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 it works
Read it, see it, practise it
Each lesson explains one topic clearly, shows worked examples, checks your understanding with quick questions and ends with a practical task you complete yourself.
Clear explanations
Step-by-step lessons in plain language
36 in this course
Worked examples
Real code and examples you can copy and run
59 in this course
Quick checks
Test your understanding as you go
11 in this course
Fill the blank
Recall the key commands and syntax
11 in this course
Hands-on workspace
A practical task at the end of every lesson
11 in this course
Syllabus
Everything you'll encounter
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
Finish the course, earn a verifiable certificate
Complete every lesson to receive a Learnix certificate with a unique number anyone can verify online.