Re: oop errors
| From: | Zeev Suraski | Date: | Fri, 09 Jun 2000 12:12:21 +0000 |
| Subject: | Re: oop errors | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-1385@lists.php.net to get a copy of this message | ||
Even assuming bar() gets called in your code snippet (which it doesn't) -
$self is a local function variable, and not an object property, so it's
not retained in the object. You need to use $this->self if you want it to
be kept inside the object.
Zeev
On Fri, 9 Jun 2000, Chandrashekhar Bhosle wrote:
>
> hi,
> Could somebody please tell me what I'm doing wrong here. I get the
> following error,
>
> <br>
> <b>Fatal error</b>: Call to a member function on a non-object in
> <b>-</b>
> on line <b>17</b><br>
>
> when I run the following script,
>
> <?
>
> class Foo {
> var $x;
>
> function bar() {
> $self->x = 1;
> echo 'self->x is: ' . $self->x;
> $self->x = 2;
> }
>
> function quux() {
> echo 'self->x is: ' . $self->x;
> }
>
> function disp() {
> $self->bar();
> $self->quux();
> }
>
> }
>
> $f = new Foo;
>
> $f->disp();
>
> ?>
>
> - cnb.
>
>
>
>
>
--
Zeev Suraski <zeev@zend.com>
http://www.zend.com/