Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Access of protected class members through derived classes
<?php class Base { protected $div = 10; } class Derived1 extends Base { public function zeroDivisor(Derived1 $obj) { $obj->div = 0; } } class Derived2 extends Base { public function zeroDivisor(Base $obj) { $obj->div = 0; } } class Derived3 extends Base { public function divide($n) { return $n / $this->div; } } $d1 = new Derived1(); $d2 = new Derived2(); $d3 = new Derived3(); $d1->zeroDivisor(new Derived1()); // this should work $d2->zeroDivisor($d3); // this should not be allowed // and why it shouldn't be allowed: in Derived3 we should // be able to assume $div cannot be changed, however: $d3->divide(1); // boom ;)
run
|
edit
|
history
|
help
0
DEV
swaping two vaiables without using third variable .
Local scop by rakib
daus
Leap Year
https://rextester.com/CQEG41074
deleted KPS from DOZ
Como extrair as informações de uma Array no MySQL?
reno
PHP Get Domain from url