View Single Post
Old 05-11-2009, 07:38 PM   #11 (permalink)
Jay
The Contributor
Good Samaritan 
 
Join Date: Dec 2007
Posts: 60
Thanks: 5
Jay is on a distinguished road
Default

Quote:
Originally Posted by Salathe View Post
Creating a singleton is not just writing a method. The idea is to only ever have one instance of the class: mixing an instance stored in a class property with the ability to create as many instances you like (via __construct) defeats the point of trying to implement the singleton pattern.
I fixed that.. that was a bug with my original code, I admit that..

But now you are free to use getInstance() or just create a new object using new.

Quote:
Originally Posted by Salathe View Post
I just used empty due to personal preference: "If not empty..." reads better, for me, than "if ... is not equal to null" and there isn't any requirement to be checking only for NULL (is there?). !== null, as you know, would work equally well in this case.
Indeed, empty() might be perceived by the human mind easier.. but I chose the !== operator because calling empty() (a function) is not necessary.. the performance benefit is trivial, I know, but that's just me
Jay is offline  
Reply With Quote