Source: programmingdive.com

What is use of final keyword in PHP?

Category: PHP

Well, in programming also it means the same.

Let’s explore use of final keyword in PHP in depth.

When we need to use final keyword to class then we just need to prefix class name with final keyword and for a method as well we need to do the same step by prefixing method name as final.

In the above examples, we first defined class classA as final which means now all the properties and methods are final and in the second example methodA is final which means now only methodA is final.

PHPs object oriented is quite late but we need to keep in mind that we can make class as a final whenever we feel that this class should never be extended.
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge. Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge.
Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Shirts painstakingly handcrafted by under-caffeinated developers. Shirts painstakingly handcrafted by under-caffeinated developers.
Community Partners