Re: Global instance of class

From: Date: Wed, 21 Nov 2001 14:41:19 +0000
Subject: Re: Global instance of class
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-75394@lists.php.net to get a copy of this message
Hi Silvia, @ 8:44:09 AM on 11/21/01, Silvia Mahiques wrote: > The code file (xxxx.php) that has this first reference is: > $global_var = new one_class(); > If I include this file (xxxx.php) in another php file, a new instance is > created again, and I want a unique instance in all project. You should only need to do this (unless I've misunderstood): if(!defined('ONE_CLASS')) { define('ONE_CLASS', 1); $global_var = new one_class(); } That should only create one instance. -- -Brian Clark | PGP is spoken here: 0xE4D0C7C8 Please, DO NOT carbon copy me on list replies.

« previous php.general (#75394) next »