Re: Could somebody PLEASE explain this one to me
| From: | Lars Torben Wilson | Date: | Wed, 30 Jan 2002 06:21:12 +0000 |
| Subject: | Re: Could somebody PLEASE explain this one to me | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-82682@lists.php.net to get a copy of this message | ||
On Tue, 2002-01-29 at 07:25, Aric Caley wrote:
> Why, oh WHY doesnt this work.
No panic, it's just a typo. :)
> I get the error:
>
> Fatal error: Call to a member function on a non-object in
> c:\home\digerati\www\classtest.php3 on line 23
>
> ???? If I try to make any assignments, anywhere, it dies. What the HELL is
> going on? Obviously I must be missing something really obvious, I Just dont
> know what it is.
>
> <?php
> class test1
> {
> function echotest()
> {
> echo "hi!";
> }
> }
>
> class test2
> {
> var $obj;
> var $test;
>
> function test2()
> {
> $this->$obj = new test1;
> $this->$test = "duh?"; //** if you take out this line, it works.
^^^^^^^^^^^^
Should be '$this->test' (no second '$').
Hope this helps,
Torben
> }
>
> function thisisatest()
> {
> $this->$obj->echotest();
> }
> }
>
> $test = new test2;
>
> $test->thisisatest();
> ?>
>
>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>
--
Torben Wilson <torben@php.net>
http://www.thebuttlesschaps.com
http://www.hybrid17.com
http://www.inflatableeye.com
+1.604.709.0506