PHP classes, traits, namespaces, interfaces, type declarations, enums, composer and PSR standards.
40 cards · basic cards · AI-written, checked twice. Edit anything.
- What keyword is used to define a class in PHP?
Show answer
class
- What visibility modifier restricts access to only within the same class?
Show answer
private
- What visibility modifier allows access within the class and its subclasses?
Show answer
protected
- What visibility modifier allows access from anywhere?
Show answer
public
- What special method is automatically called when a new object is created?
Show answer
__construct
- What keyword is used to inherit from a parent class?
Show answer
extends
- Can a class extend multiple classes in PHP?
Show answer
No, PHP only supports single inheritance
- What is an abstract class?
Show answer
A class that cannot be instantiated and is designed to be inherited
- Can abstract classes contain non-abstract (concrete) methods?
Show answer
Yes, abstract classes can mix abstract and concrete methods
- What keyword prevents a class from being extended?
Show answer
final
- What does the final keyword do when applied to a method?
Show answer
Prevents the method from being overridden in subclasses
- What is a trait in PHP?
Show answer
A mechanism for reusing methods in multiple, unrelated classes
- How many traits can a single class use?
Show answer
Multiple traits
- What keyword includes a trait within a class body?
Show answer
use
- What keyword resolves conflicts when two traits define the same method?
Show answer
insteadof