Home>Article>Backend Development> Final journey of this life

Final journey of this life

autoload
autoload Original
2021-03-04 10:51:24 1951browse

First of all, the division of transactions cannot be infinitely refined, so there is definitely no need for infinite subclasses. Once subclasses appear infinitely, it may not bring convenience in solving problems, but infinite consumption of memory resources. Therefore,PHPprovides a termination mechanism so that classes cannot be inherited.

1. Basic syntax:final class class name

2. The final class cannot be inherited

3.finalThe keyword not only modifies the class to indicate that the class cannot be inherited, but also modifies the method, indicating that the method cannot be overridden

Summary: The final keyword modification represents the possibility of being unchangeable in variables, represents that it cannot be inherited in classes, and cannot be overridden in methods.

Recommended:php tutorial,php video tutorial

The above is the detailed content of Final journey of this life. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn