Re: Overriding Class functions and variables
| From: | Analysis & Solutions | Date: | Mon, 03 Jun 2002 22:02:47 +0000 |
| Subject: | Re: Overriding Class functions and variables | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-100474@lists.php.net to get a copy of this message | ||
Jared:
On Mon, Jun 03, 2002 at 04:33:45PM -0400, Jared Boelens wrote:
> In my case i am trying to override a variable. I have a property Username
> for both the parent and the child. I am wondering if there is a way to
> differenciate between parent->Username and child->Username.
Are you talking about a child class that extends another parent class,
or something similar? Kind of like this:
class FooParent {
var $Username = '1';
}
class FooChild extends FooParent {
var $Username = '2';
}
$F = new FooChild;
echo $F->Username;
If so, then, no, I don't think there's a way to distinguish the two.
The second instance will prevail.
To distinguish, you could create two separate object names...
$F1 = new FooParent;
$F2 = new FooChild;
echo "$F1->Username and $F2->Username";
Or perhaps calling two instances of the class into separate object
names, then modify one instance of the Username variable...
$F1 = new FooChild;
$F2 = new FooChild;
$F1->Username = '3';
echo "$F1->Username and $F2->Username";
All depends on what you're trying to do.
Enjoy,
--Dan
--
PHP classes that make web design easier
SQL Solution | Layout Solution | Form Solution
sqlsolution.info | layoutsolution.info | formsolution.info
T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y
4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409