Re: [PHP4BETA] What am I doing wrong?

From: Date: Sun, 23 Apr 2000 08:39:57 +0000
Subject: Re: [PHP4BETA] What am I doing wrong?
References: 1  Groups: php.version4 
Request: Send a blank email to php-version4+get-13934@lists.php.net to get a copy of this message
ARRRRGH!!!! After finding out that there are no implicit "this" pointers, I went nuts adding $this-> before all of my sets. Well, $this->$my_variable="foo"; doesn't work as I guessed...it's $this->my_variable="foo"; All better now.... anyone else think this might be a good thing to be in the doc? Maybe we can get a design alias on the resolution of $ such that when resolving $ it strips out "extra" $'s? $this->some_embedded_object->some_variable = "foo"; or $this->$some_embedded_object->some_variable = "foo"; What's the resolution on this last one? -Szii "It only cost me 2 days..." "I'm not dead yet...I'm getting better!" "No you're not." "Yes I am!" At 01:00 AM 4/23/00 -0700, Szii wrote: >Um, what's wrong with this? My object seems to be getting corrupted... > > ><?php > session_start(); ># require("classes/test.class"); > if (!isset($user_object)) > { > $user_object = new test(); > session_register("user_object"); > } >?> ><html> ><body> >Here is our object!<BR> ><?php $user_object->printvalues(); ?> >Now we don't use the constructor set, but >call it directly...<BR> ><?php $user_object->LoadStuff(); ?> >Here is the new object!<BR> ><?php $user_object->printvalues(); ?> > ></body> ></html> > ><?php >class test >{ > var $one; > var $two; > var $three; > var $four; > var $five; > var $six; > var $seven; > var $eight; > var $nine; > var $ten; > > function test() > { > $this->LoadStuff(); > } > > function LoadStuff() > { > $this->$one = "one1"; > $this->$two = "two2"; > $this->$three = "three3"; > $this->$four = "four4"; > $this->$five = "five5"; > $this->$six = "six6"; > $this->$seven = "seven7"; > $this->$eight = "eight8"; > $this->$nine = "nine9"; > $this->$ten = "ten10"; > } > > function printvalues() > { > print ($this->$one . "\r\n<BR>"); > print ($this->$two . "\r\n<BR>"); > print ($this->$three . "\r\n<BR>"); > print ($this->$four . "\r\n<BR>"); > print ($this->$five . "\r\n<BR>"); > print ($this->$six . "\r\n<BR>"); > print ($this->$seven . "\r\n<BR>"); > print ($this->$eight . "\r\n<BR>"); > print ($this->$nine . "\r\n<BR>"); > > function printvalues() > { > print ($this->$one . "\r\n<BR>"); > print ($this->$two . "\r\n<BR>"); > print ($this->$three . "\r\n<BR>"); > print ($this->$four . "\r\n<BR>"); > print ($this->$five . "\r\n<BR>"); > print ($this->$six . "\r\n<BR>"); > print ($this->$seven . "\r\n<BR>"); > print ($this->$eight . "\r\n<BR>"); > print ($this->$nine . "\r\n<BR>"); > print ($this->$ten . "\r\n<BR>"); > } >} > >?> > > >-- >PHP 4.0 Beta Mailing List <http://www.php.net/version4/> >To unsubscribe, e-mail: php4beta-unsubscribe@lists.php.net >For additional commands, e-mail: php4beta-help@lists.php.net >To contact the list administrators, e-mail: php4beta-admin@lists.php.net > > >

« previous php.version4 (#13934) next »