Skip to content

Instantly share code, notes, and snippets.

@jaceju
Created January 11, 2013 06:04
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jaceju/4508327 to your computer and use it in GitHub Desktop.
Save jaceju/4508327 to your computer and use it in GitHub Desktop.
<?php
trait Singleton
{
protected static $_instance = null;
public static function getInstance()
{
if (static::$_instance === null
|| !(static::$_instance instanceof static)) {
static::$_instance = new static();
}
return static::$_instance;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment