This article mainly introduces the final keyword usage in PHP, combined with examples to analyze the final keyword functions, use methods and related considerations, the need for friends can refer to the following
This example describes the final keyword usage in PHP. Share to everyone for your reference, as follows:
The final keyword can only be used to define classes and define methods.
Classes marked with the final keyword cannot be inherited
Final class person{... } Class Student extends person{... }
An error message will appear. Fatal Error:class Student may not inherit from final Class (person)
Methods marked with the final keyword cannot be overridden by a quilt class
Class person{ final function Say () { ... }} Class Student extends person{ function Say () { ... }}
The following error will appear:
Fatal error:cannot Override Final Method Person::say ()
The above is the whole content of this article, I hope that everyone's study has helped.