Singleton, the PHP way
I realized that even if the great part of my work consists in programming PHP stuff, I rarely write about PHP in my posts, maybe because I really don't like it?
But today I'll write about a way to implement the singleton pattern with PHP.
This is quite an easy job making use of PHP 5.3.0, thanks to the "Late Static Binding" feature. In particular we'll use the get_called_class
method and the static
keyword. Notice that ...