PDA

View Full Version : Variable overloading issue in PHP


amber.long83
06-19-2009, 05:31 PM
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
/ 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

Can anyone guide me?