Recall & Review
beginner
What is a static property in PHP?
A static property belongs to the class itself, not to any object instance. It is shared by all instances of the class.Click to reveal answer
beginner
How do you access a static property inside a class method?Use
self::$propertyName to access a static property inside the class.Click to reveal answer
beginner
What is a static method in PHP?
A static method belongs to the class and can be called without creating an object instance.Click to reveal answer
beginner
How do you call a static method from outside the class?
Use
ClassName::methodName() to call a static method without creating an object.Click to reveal answer
intermediate
Can static methods access non-static properties in PHP?
No, static methods cannot access non-static properties because they do not belong to any object instance.
Click to reveal answer
How do you define a static property in a PHP class?
✗ Incorrect
Static properties are declared with the
static keyword inside the class.How do you call a static method named
show in class Example?✗ Incorrect
Static methods are called using the class name and double colon:
Example::show().Which keyword is used inside a class to refer to its own static property?
✗ Incorrect
Inside a class,
self::$propertyName accesses static properties.Can static properties have different values for each object instance?
✗ Incorrect
Static properties belong to the class, so all instances share the same value.
Which of the following is true about static methods?
✗ Incorrect
Static methods belong to the class and can be called without creating an object.
Explain what static properties and static methods are in PHP and how they differ from regular properties and methods.
Think about how you can use a property or method without making an object.
You got /4 concepts.
Describe how to access a static property and call a static method inside and outside a PHP class.
Remember the special syntax for static members.
You got /4 concepts.