Skip to content

Instantly share code, notes, and snippets.

@aklesky
Created December 4, 2014 17:05
Show Gist options
  • Select an option

  • Save aklesky/af63ac88c8b59adf00dc to your computer and use it in GitHub Desktop.

Select an option

Save aklesky/af63ac88c8b59adf00dc to your computer and use it in GitHub Desktop.
PHP Singletone
<?php
static public function getInstance()
{
static $instance;
$class = get_called_class();
if (!($instance instanceof $class)) {
$reflection = new \ReflectionClass($class);
$instance = $reflection->newInstanceArgs(func_get_args());
}
return $instance;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment