RE: [PHP] class problems

From: Date: Thu, 18 Oct 2001 13:50:45 +0000
Subject: RE: [PHP] class problems
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-71489@lists.php.net to get a copy of this message
Ok got it from here. http://uk.php.net/manual/en/keyword.paamayim-nekudotayim.php using :: allows use of a class function but doesn't allow access the object, so to access $this I do need to instantiate the class Thanks M: > Try to create an instant of the class like this: > <?php > class test > { > var $table = "val"; > > function showName() > { > return $this->table; > } > > } > $test = new Test; > echo $test->showName(); > > ?> > M: > -----Original Message----- > From: Valentin V. Petruchek [mailto:petruchek@zsu.zp.ua] > Sent: 18 October 2001 14:39 > To: php-general@lists.php.net > Subject: Re: [PHP] class problems > > > Try to create an instant of the class like this: > <?php > class test > { > var $table = "val"; > > function showName() > { > return $this->table; > } > > } > $test = new Test; > echo $test->showName(); > > ?> > ----- Original Message ----- > From: "Matt Williams" <matt@yewlands.com> > To: "PHP General List" <php-general@lists.php.net>; "PHP_UK@egroups." > <PHP_UK@egroups.com> > Sent: Thursday, October 18, 2001 4:25 PM > Subject: [PHP] class problems > > > > Any ideas why this won't output anything > > > > <?php > > class test > > { > > var $table = "matt"; > > > > function showName() > > { > > return $this->table; > > } > > > > } > > > > echo test::showName(); > > > > ?> > > > > I have other classes along the similar lines but a lot bigger which work > > fine. > > I'm also using phplib which has a lot of this stuff going on... > > > > I remeber seeing something regarding it in the manual but i > don't get how > > it's all worked before. > > > > I'm using php4.06 apache 1.3.19 on win2k. > > > > TIA > > > > M: > > > > > > -- > > 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 > > > > > > > > -- > 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 >

« previous php.general (#71489) next »