How can you prevent a class from being inherited by another class in PHP?
- Declare it as 'final'
- Declare it as 'static'
- Declare it as 'const'
- Declare it as 'sealed'
To prevent a class from being inherited, you declare it as 'final.' The 'final' keyword indicates that the class cannot be extended by other classes.
Loading...
Related Quiz
- What are some common practices in PHP when dealing with JSON data?
- Which of the following statements in PHP can output strings, variables, and HTML code?
- What is the purpose of the assignment operators in PHP?
- What are the differences between a class constant and a class variable in PHP?
- You are writing a PHP script and you decide to use Object-Oriented Programming. How would you define a class?