PHP for Luau Developers
Transfer your Luau experience to PHP 8.3: values, control flow, arrays, functions, exceptions and object design. Build a multi-file time ledger with validated parsing and deterministic reports.
Luau and PHP side by side
The same program in Luau and in PHP, from the lessons of this course.
Modules and first run
Luau is embedded in a host that supplies entry and module conventions; this CLI supports relative require paths. PHP executes an entry file and loads declarations with require_once. Use __DIR__ for PHP dependencies and keep reusable modules free of top-level…
Luau1print("hello CLI")PHP1<?php2declare(strict_types=1);3echo "hello CLI\n";Branches and precedence
Luau if expressions select values directly, while and/or short-circuit and return operands. PHP uses ?: for conditional values and &&/|| for Boolean results; and/or have lower precedence. Translate the intended grouping and result type rather than copying…
Luau1local n: number=10;print(if n>=0 and n<=10 then "in" else "out")PHP1<?php2declare(strict_types=1);3$n=4; echo $n>3?"high":"low"; echo "\n";Lists are PHP arrays
Luau sequences normally use consecutive keys from one, and table.remove shifts later sequence entries. PHP arrays are ordered maps; unset can leave numeric gaps. Use array_values for a required dense PHP list, and do not apply Luau length assumptions to…
Luau1local values={"a","b","c"};table.remove(values,2);print(table.concat(values,","))PHP1<?php2declare(strict_types=1);3$a=[10,20,30]; unset($a[1]); echo implode(",",array_keys($a)),"\n";Functions and return types
Luau optional annotations describe static call contracts and can express multiple returned values, but they do not insert PHP-style runtime scalar checks. PHP parameter and return declarations enforce runtime boundaries. A PHP array type still does not…
Luau1local function twice(n: number): number return n*2 end;print(twice(3))PHP1<?php2declare(strict_types=1);3function surround(string $s):string{return "(".$s.")";} echo surround("note"),"\n";Exceptions and state
Luau error unwinds to a protected pcall or xpcall, which reports success and results instead of using catch syntax. PHP throws Throwable objects and offers typed catch and finally. Validate before mutation and translate expected failures without hiding…
Luau1local value=4;local ok=pcall(function()error("bad");value=9 end);print(tostring(ok)..":"..value)PHP1<?php2declare(strict_types=1);3try {throw new RuntimeException("bad");} catch(RuntimeException $e){echo "caught";} finally{echo ":done\n";}Classes and typed properties
Luau can describe table shapes with static types while runtime objects are still tables with explicit fields and metatables. PHP classes enforce declared property types at runtime and uninitialized typed properties cannot be read safely. Establish state…
Luau1local a={points=3};local b={points=5};print(a.points+b.points)PHP1<?php2declare(strict_types=1);3class Flag {public bool $enabled=false;} $f=new Flag(); echo $f->enabled?"on\n":"off\n";
Syllabus
10 chapters48 lessons1 project48 challenges99 quiz questionsValues and output
7 lessonsControl flow
5 lessonsCollections
6 lessonsFunctions and modules
6 lessonsErrors and boundaries
4 lessonsObjects and state
4 lessonsObject contracts
6 lessonsSharing and identity
4 lessonsTime ledger project
4 lessonsFinal challenges
2 lessonsFrequently asked questions
Who is PHP for Luau Developers for?
For people who already write Luau and want to learn PHP. Each lesson starts from Luau you know and shows how PHP does the same thing, so you skip the beginner basics.
Do I need to know PHP already?
No. The course starts with your first PHP program. You need Luau basics: variables, conditions, loops, functions and collections.
How many lessons does PHP for Luau Developers have?
PHP for Luau Developers contains 48 interactive lessons you can complete at your own pace.
What does PHP for Luau Developers cover?
The course is organized into chapters covering: Values and output, Control flow, Collections, Functions and modules, and more.
Is PHP for Luau Developers free?
Yes. Every course on Coddy is free to start. You can complete lessons in your browser without any downloads or signup.