I just went to order the book on bookpool.com, but its out of stock.
I'll wait a bit and get it soon. Thanks.
- Ben
When you get the book (or sooner if you look online), you should
check out the Singleton pattern.
If your class method can't be static (because it needs access to
$this - which isn't available for static methods), then a Singleton
is a good option to use if you only need one instance of the object
in your app.
It works basically like this:
class Error
{
private static $_instance = null;
public static function singleton()
{
if (self::$_instance === null) {
self::$_instance = new Error();
}
return self::$_instance;
}
}
Then, wherever you need to get your Error object, just call
$error = Error::singleton();
-Rob
_______________________________________________
New York PHP Community Talk Mailing List
http://lists.nyphp.org/mailman/listinfo/talk
NYPHPCon 2006 Presentations Online
http://www.nyphpcon.com
Show Your Participation in New York PHP
http://www.nyphp.org/show_participation.php