Possible Duplicate:
In a PHP5 class, when does a private constructor get called?
I have been reading about OOP recently and came across this private constructor scenario. I did a Google search, but couldn’t find anything relevant to PHP.
In PHP
- When do we have to define a private constructor?
- What’s the purpose of using a private constructor?
- What are the pros & cons of using a private constructor?
When do we have to define a private constructor?
What’s the purpose of using a private constructor?
It ensures that there can be only one instance of a Class and provides a global access point to that instance and this is common with The Singleton Pattern.
What are the pros & cons of using a private constructor?
Are Singletons really that bad?
What is so bad about singletons?