When to use Final in PHP

0 votes

Although I am aware of what a final class is, I am curious about how and when it is actually necessary.

<?php
final class Foo extends Bar
{
   public function()
   {
     echo 'John Doe';
   }
}

If I've got it right, "final" allows it to extend "Foo.".

Can somebody tell me when and why to use the word "final"? I.e., is there any justification for not extending a class?

It would be useful to construct a class that extends "Bar" if, for instance, classes "Foo" and "Bar" are missing some features.

Jul 24 in PHP by Kithuzzz
• 3,660 points
14 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In PHP

0 votes
1 answer

Error:Issue when trying to use IN() in wordpress database

Hello @kartik, Try this code : // Create an ...READ MORE

answered May 8, 2020 in PHP by Niroj
• 82,740 points
364 views
0 votes
2 answers

How to use basic authorization in PHP curl?

If you are saying Basic authentication, then ...READ MORE

answered Jan 3, 2021 in PHP by Manas
• 140 points
14,180 views
0 votes
0 answers

when to use index.php instead of index.html

I wanted to know when do I ...READ MORE

May 30 in PHP by Kichu
• 19,040 points
24 views
0 votes
0 answers

How to efficiently use try...catch blocks in PHP

I was using try..catch blocks in my ...READ MORE

Jun 1 in PHP by Kichu
• 19,040 points
19 views
0 votes
0 answers
0 votes
0 answers

Is it possible to write strictly typed PHP code?

Is it possible to write code like ...READ MORE

Jun 6 in PHP by Kichu
• 19,040 points
12 views
0 votes
0 answers

What does the variable $this mean in PHP?

Can someone please explain how the variable ...READ MORE

Jun 11 in PHP by narikkadan
• 11,280 points
13 views
0 votes
0 answers

What is the difference between public, private, and protected?

When and why should I use public, ...READ MORE

Jun 16 in PHP by narikkadan
• 11,280 points
15 views
0 votes
0 answers

Advantages and Disadvantages of Inheritance in php

Could someone please explain the main benefits ...READ MORE

Jul 28 in PHP by Kithuzzz
• 3,660 points
10 views
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP