OO php: static and factory classes
charlescurley at charlescurley.com
Fri Aug 31 15:34:28 MDT 2007
I'd like to build a factory class (all static methods) called Images
that will that create, store, etc. instances of another class,
Image. I can create image and Images, but I have to instantiate Images
in order to call a factory method. This works:
$snark = new Images ();
$countImages = $snark->imageCount ($client_id, $db, __LINE__, __FILE__);
but this does not:
$countImages = $Images->imageCount ($client_id, $db, __LINE__, __FILE__);
The docs say the second should work:
Declaring class members or methods as static makes them accessible
without needing an instantiation of the class. A member declared as
static can not be accessed with an instantiated class object (though
a static method can).
// The factory class for the image class.
public static function imageCount ($client, $db, $line, $file)
PHP verson is Version 5.1.4.
Charles Curley /"\ ASCII Ribbon Campaign
Looking for fine software \ / Respect for open standards
and/or writing? X No HTML/RTF in email
http://www.charlescurley.com / \ No M$ Word docs in email
Key fingerprint = CE5C 6645 A45A 64E4 94C0 809C FFF6 4C48 4ECD DFDB
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 189 bytes
Desc: not available
Url : http://plug.org/pipermail/plug/attachments/20070831/daca6841/attachment.bin
More information about the PLUG