How can you prevent the inheritance of an exception class in PHP?

  • Declare the exception class as 'final'
  • Use 'private' inheritance
  • Implement 'protected' inheritance
  • Use 'static' keyword inheritance
In PHP, you can prevent inheritance of a class by declaring it as 'final.' This ensures that no other class can extend it. Exception classes are often made final to prevent further customization or accidental overriding of their behavior.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *