Hi friends Thanks for visiting my post.
Variable overloading issue in PHP
3
Hi friends
Thanks for visiting my post.
I have a issue in object inheritance in php. I have two classes which extends other. There is one common variable name used in both the class. So it's creating a conflict while accessing the parent class variable. Let me explain this by example
Can anyone guide me?
Thanks for visiting my post.
I have a issue in object inheritance in php. I have two classes which extends other. There is one common variable name used in both the class. So it's creating a conflict while accessing the parent class variable. Let me explain this by example
PHP Code:
// First Class
class a {
public $email = "a@a.com";
}
class b extends a {
public $email = "b@b.com";
}
$obj = new b();
echo $obj->email; // this will print b@b.com but i want to print a@a.com
- CMartin
- titleless Banned
- [1] reply
- amber.long83
Next Topics on Trending Feed
-
3