Menu
CoddyTech
Course

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.

  1. 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…

    PHP
    1<?php2declare(strict_types=1);3echo "tag ",7,"\n";4echo "# data\n";
    GDScript
    1extends Node2
    3func _ready() -> void:4	print("tag", 7)5	print("# data")
  2. 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…

    PHP
    1<?php2declare(strict_types=1);3$n=-2; echo $n<0 ? "west\n" : "east\n";
    GDScript
    1extends Node2
    3func _ready() -> void:4	var n: int = -25	print("west" if n < 0 else "east")
  3. 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…

    PHP
    1<?php2declare(strict_types=1);3$items=[3]; $items[]=8; $removed=array_pop($items); echo $removed," ",count($items),"\n";
    GDScript
    1extends 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()])
  4. 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…

    PHP
    1<?php2declare(strict_types=1);3$s="a-b-a"; $t=str_replace("-","/",$s); echo $s," ",$t,"\n";
    GDScript
    1extends Node2
    3func _ready() -> void:4	var s: String = "a-b-a"5	var t: String = s.replace("-","/")6	print(s," ",t)
  5. 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…

    PHP
    1<?php2declare(strict_types=1);3class Token { public string $text=""; }
    GDScript
    1class_name DemoToken2extends RefCounted3var text: String = "blue"
  6. 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:…

    PHP
    1<?php2declare(strict_types=1);3class Base { public function label(): string { return "base"; } }
    GDScript
    1class_name DemoBase2extends RefCounted3func label() -> String:4	return "base"

Syllabus

10 chapters48 lessons1 project48 challenges99 quiz questions

More courses for PHP developers

Learn GDScript from another language

Frequently 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.

Coddy programming languages illustration

Start GDScript for PHP Developers for free

Get started