What is the use of final keyword in PHP???
Final Keyword
Collapse
X
-
Tags: None
-
PHP 5 introduces the final keyword, which prevents child cl***es from overriding a method by prefixing the definition with final. If the cl*** itself is being defined final then it cannot be extended.Properties cannot be declared final, only cl***es and methods may be declared as final. -
The final keyword prevents child cl***es from overriding a method or constant by prefixing the definition with final . If the cl*** itself is being defined final then it cannot be extended. Note: Properties cannot be declared final: only cl***es, methods, and constants (as of PHP 8.1).Comment
-
The final keyword is a non-access modifier used for cl***es, attributes and methods, which makes them non-changeable (impossible to inherit or override). The final keyword is useful when you want a variable to always store the same value, like PI (3.14159...). The final keyword is called a "modifier".Comment
Comment