Can I use an abstract class instead of a private __construct() when creating a singleton in PHP?

When creating a singleton in PHP, declaring the construct and clone as private ensures that the class cannot be instanciated from the outside : it can still be instanciated from inside its declaration.

No because then then you can't instantiate the class at all (not even in the static getInstance method). The private constructor in the singleton example just assures, that only the static getInstance method from the same class can access the constructor.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions