I’m building a database abstract layer in PHP using a Singleton pattern, I based my code the following article.
In the comments, I found that you can self-instantiate a class with “self” instead of calling it by name, very useful if you plan to change the class name over time.
Must re-write code if you change the class name:
self::$m_pInstance = new Database();
No worries with self():
self::$m_pInstance = new self();
0 comments:
Post a Comment