Re: [PHP] var static

2003-08-28 Thread Jordan S. Jones
If I were you, I would use the following: if (!is_a ($miInstancia, 'db')) $miInstancia=new db(); That way you can ensure that the variable has been instantiated and is an instance of the db class.. But it may not really matter.. Jordan S. Jones Alvaro Martinez wrote: I've found the solution m

Re: [PHP] var static

2003-08-28 Thread Robert Cummings
Globals!? YUCK :) A better solution IMHO that maintains encapsulation, is to use a static var in a function: function &getClassVar( $name ) { return getAndSetClassVar( $name, false ); } function &setClassVar( $name, $value ) { return getAndSetClassVar( $name, true, $value ); } function &

Re: [PHP] var static

2003-08-28 Thread Alvaro Martinez
I've found the solution myself. The db class is the next: class db{ function db (){ // funcion que se conecta con la BBDD $result = @mysql_pconnect("inforalv", "discoteca", "password"); if (!$result) return false; if ([EMAIL PROTECTED]("discoteca")) return false; } function &getInstancia(){ stat

Re: [PHP] var static

2003-08-28 Thread Tom Rogers
Hi, Friday, August 29, 2003, 3:01:45 AM, you wrote: AM> I want to obtain only one instance of one class. In other to do that, I call AM> to a static method, that creates the instance(if it doesnt exit) or returns AM> the reference of the instance. AM> The call to the static method is the next: AM

RE: [PHP] var static

2003-08-28 Thread Dynamical.biz
Although PHP supports static variables in functions (see here), it has no support for static variables in classes. http://www.php.net/manual/en/language.variables.scope.php (espero que te sirva) saludos aniceto lópez :: DYNAMICAL.BIZ web development & host services Barcelona - Spain -Me