GDScript for PHP Developers
Move from PHP to Godot 4 GDScript: typing, array ownership, Unicode, callables, classes, signals and explicit failures. Build a connected stock depot and port two PHP programs across 48 multi-file lessons.
PHP and GDScript side by side
The same program in PHP and in GDScript, from the lessons of this course.
Text and Comments
PHP echo writes its arguments without automatic spacing or a newline; include both explicitly. GDScript print also joins arguments without spaces but appends a newline. PHP accepts # and // line comments, while GDScript uses # and indentation rather than…
PHP1<?php2declare(strict_types=1);3echo "tag ",7,"\n";4echo "# data\n";GDScript1extends Node2 3func _ready() -> void:4 print("tag", 7)5 print("# data")Branches and Values
PHP uses braces and condition ? yes : no for conditional selection. GDScript uses indentation, elif and yes if condition else no. Both select one branch. PHP truthiness and loose comparisons can accept values outside the intended domain, so use explicit…
PHP1<?php2declare(strict_types=1);3$n=-2; echo $n<0 ? "west\n" : "east\n";GDScript1extends Node2 3func _ready() -> void:4 var n: int = -25 print("west" if n < 0 else "east")Array Operations
PHP arrays are ordered maps that support integer and string keys; a list is one particular key arrangement. GDScript Array is an indexed sequence, while Dictionary is the mapping type. PHP [] appends and array_pop removes the last entry. Unsetting a PHP…
PHP1<?php2declare(strict_types=1);3$items=[3]; $items[]=8; $removed=array_pop($items); echo $removed," ",count($items),"\n";GDScript1extends Node2 3func _ready() -> void:4 var items: Array = [3]5 items.append(8)6 var removed = items.pop_back()7 print("%d %d" % [removed,items.size()])String Operations
PHP str_replace performs literal replacement and returns a new string value. GDScript String.replace likewise returns the replaced text. Retain the result explicitly; merely calling either function does not rebind the original variable. PHP strings can also…
PHP1<?php2declare(strict_types=1);3$s="a-b-a"; $t=str_replace("-","/",$s); echo $s," ",$t,"\n";GDScript1extends Node2 3func _ready() -> void:4 var s: String = "a-b-a"5 var t: String = s.replace("-","/")6 print(s," ",t)Scripts as Classes
PHP class declarations define object types, and assigning an object variable copies its object identifier rather than cloning the object. GDScript scripts define classes, class_name registers a global name and new constructs an instance. RefCounted is suited…
PHP1<?php2declare(strict_types=1);3class Token { public string $text=""; }GDScript1class_name DemoToken2extends RefCounted3var text: String = "blue"Inheritance and Super
PHP classes and GDScript scripts each extend one direct superclass. PHP supports interfaces and traits as separate mechanisms. Overridden instance methods dispatch according to the object type unless access or final rules prevent overriding. PHP parent:…
PHP1<?php2declare(strict_types=1);3class Base { public function label(): string { return "base"; } }GDScript1class_name DemoBase2extends RefCounted3func label() -> String:4 return "base"
Syllabus
10 chapters48 lessons1 project48 challenges99 quiz questionsScripts and Scalar Values
6 lessonsFlow and Functions
6 lessonsCollection Ownership
6 lessonsText and Callable Values
3 lessonsObjects and State
5 lessonsObject Relationships
5 lessonsEvents and Failure
5 lessonsBoundaries and Lifetimes
6 lessonsConnected Stock Depot
Project4 lessonsFinal Ports
2 lessonsFrequently asked questions
Who is GDScript for PHP Developers for?
For people who already write PHP and want to learn GDScript. Each lesson starts from PHP you know and shows how GDScript does the same thing, so you skip the beginner basics.
Do I need to know GDScript already?
No. The course starts with your first GDScript program. You need PHP basics: variables, conditions, loops, functions and collections.
How many lessons does GDScript for PHP Developers have?
GDScript for PHP Developers contains 48 interactive lessons you can complete at your own pace.
What does GDScript for PHP Developers cover?
The course is organized into chapters covering: Scripts and Scalar Values, Flow and Functions, Collection Ownership, Text and Callable Values, and more.
Is GDScript for PHP Developers free?
Yes. Every course on Coddy is free to start. You can complete lessons in your browser without any downloads or signup.