Test yourself under real exam conditions: 50 timed questions, 60 on the clock, pass mark 70%%. Instant score with a full review of everything you got wrong. Free — no account needed.
Exam details
A class is a blueprint for creating objects. It defines properties (variables) and methods (functions) that the objects will have.class User { public string $name; }
public – accessible from anywhere.
protected – accessible within the class and its subclasses.
private – accessible only within the defining class.
These are known as access modifiers.
Use the new keyword:$user = new User();
This calls the class constructor (__construct) if one is defined.
__construct() is the constructor that runs automatically when an object is created with new.public function __construct(public string $name) {}
It initializes object properties.
Inheritance lets a child class extend a parent class using the extends keyword.class Admin extends User {}
The child inherits all public and protected properties and methods.