how to check if object of a class already exists in PHP?
<p>consider the following code scenario:</p>

<pre><code>&lt;?php

//widgetfactory.class.php
// define a class
class WidgetFactory
{
  var $oink = 'moo';
}

?&gt;


&lt;?php

//this is index.php
include_once('widgetfactory.class.php');

// create a new object
//before creating object make sure that it already doesn't exist

if(!isset($WF))
{
$WF = new WidgetFactory();
}

?&gt;
</code></pre>

<p>The widgetfactory class is in widgetfactoryclass.php file,  I have included this file in my index.php file, all my site actions runs through index.php, i.e. for each action this file gets included, now I want to create object of widgetfactory class ONLY if already it doesn't exist. I am using <code>isset()</code> for this purpose, is there any other better alternative for this?</p>
