Advertisement
Guest User

David

a guest
Nov 16th, 2009
590
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.44 KB | None | 0 0
  1. <?php
  2.  
  3. /**
  4. * Singleton
  5. * @author David Hopkins (semlabs.co.uk)
  6. * @version 0.1
  7. */
  8.  
  9. class Sing
  10. {
  11.    
  12.     function &get( $name, $args = array() )
  13.     {
  14.         static $instance;
  15.        
  16.         if( !isset( $instance ) )
  17.             $instance = array();
  18.        
  19.         if( !isset( $instance[$name] ) )
  20.         {
  21.             $instance[$name] = new ReflectionClass( $name );
  22.             $instance[$name] = $instance[$name]->newInstanceArgs( $args );
  23.         }
  24.        
  25.         return $instance[$name];
  26.     }
  27.  
  28. }
  29.  
  30. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement