Skip to main content
PHP Code Reorder Medium +20 XP

OOP Constructor

Arrange the PHP class with constructor.

Click lines in the correct order

Available lines4 left

Your order

Click lines above to build your solution.

Show answer and explanation

Answer: class Person { public $name; public function __construct($name) { $this->name = $name; } }

Class declaration wraps the property and constructor. Properties are typically declared before methods.

Hint: class keyword first, then properties, then constructor.

What this challenge tests

Code Reorder in PHP: oop, classes.

Related challenges