Re: Class constructor

From: Date: Mon, 03 Jul 2000 03:07:41 +0000
Subject: Re: Class constructor
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-818@lists.php.net to get a copy of this message
I'm going to answer my own question. The dollar sign isn't used when describing an object variable. So it's $this->x not $this->$x. And $o->x not $o->$x. Thanks me > Can someone tell me why the following doesn't work? The Cobj function is > supposed to be a constructor to initialize the $x variable when a new instance > of the Cobj class is created. > > I get no errors, but there's no output from echo. > > > class Cobj { > function Cobj ($x) { > $this->$x = $x; > } > } > > > $o = new Cobj("this"); > > echo $o->$x; > > > > > Thanks in advance,

« previous php.db (#818) next »