Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

prevent php classes from being extends

Tags:

php

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

like image 231
Mac Os Avatar asked Dec 13 '22 06:12

Mac Os


2 Answers

Use the final keyword.

like image 161
Timur Avatar answered Jan 01 '23 05:01

Timur


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

or

class A {
  final public function test($value){
like image 22
Corubba Avatar answered Jan 01 '23 03:01

Corubba