简体   繁体   中英

prevent php classes from being extends

some time i trying to decode my own general file that contain the all important functions in a class but i think when i have class like

class A {
  public function test($value){

and the file encoded

may be some one do that

class B extends A {
  public function test($value){

and change the whole function that contain my code that i can expose my control

http://www.php.net/manual/en/language.oop5.php

使用final关键字。

final class A {
  public function test($value){

or

class A {
  final public function test($value){

使用最终关键字

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM