Re: global class instance

From: Date: Wed, 05 Jul 2006 19:30:33 +0000
Subject: Re: global class instance
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-239150@lists.php.net to get a copy of this message
On 7/1/06, sempsteen <sempsteen@gmail.com> wrote:
hi all, i wonder if there is a way of creating an instance of a class and reach it direcly from any scope in PHP4. basically what i want is: class a { function print() {
      echo 'sth';
} } $a = new a(); and use this "a" instance from anywhere ex, in a function that is a method of another class. class b { function print() {
      $a->print();
} } i don't want to: - declare global $foo, - use pre-defined $GLOBALS variable, - or use a::print thanks. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Static is your friend. http://www.horde.org/papers/kongress2002-design_patterns/11_singleton_impl.xml.html

« previous php.general (#239150) next »