This site is mobile accessible. Press the "Tap Here" button to use a different font-size.


Smartphone icons created by Freepik - Flaticon

PHP Inheritance

The final Keyword

<?php
final class Fruit {
}

// this causes a fatal error that prevents the page displaying
class Strawberry extends Fruit {
}

?>

The above code results in a fatal error that prevents the page loading. Because of this I did not run the code. Below is the error message from the server logs.

[php7:error] [pid 5381] [client ::1:49710] 
PHP Fatal error:  Class Strawberry may not inherit from final class (Fruit) in:
 /srv/www/htdocs/W3School-WebDevelopment/php/PHPInheritance4.php on line 32