RE: [PHP] Class Instance Inheritance
| From: | Ed Lazor | Date: | Mon, 13 Sep 2004 17:53:57 +0000 |
| Subject: | RE: [PHP] Class Instance Inheritance | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-196539@lists.php.net to get a copy of this message | ||
Here's one way, but this may not be completely what you want because the
value of variable foo doesn't change.
-Ed
Class foo
{
Static $foo;
Function foo() {
$this->foo = 10;
}
}
> -----Original Message-----
> From: Gerard Samuel [mailto:php-general@trini0.org]
> Sent: Monday, September 13, 2004 10:15 AM
> To: php-general
> Subject: [PHP] Class Instance Inheritance
>
> Is it possible for a class to extend the state of its parent class?
> In the example provided, I was hoping for the statement to say ->
> "I wish 10 equals to 10"
> If there is a solution, I would like it to work with php 4+
> Thanks
>
> -----
>
> class foo
> {
> var $foo = 0;
> }
>
> $foo = new foo;
> $foo->foo = 10;
>
> class bar extends foo
> {
> function bar()
> {
> echo "I wish $this->foo equals to 10";
> }
> }
>
> $bar = new bar;
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php