Skip to content

Instantly share code, notes, and snippets.

@h2rd
Created January 2, 2012 23:18
Show Gist options
  • Save h2rd/1552578 to your computer and use it in GitHub Desktop.
Save h2rd/1552578 to your computer and use it in GitHub Desktop.
<?php
class UniqId {
public static function get() {
static $db = null;
if ( $db == null ) {
$db = new UniqId();
}
return $db;
}
private $_handle = null;
private function __construct() {
$this->_handle = uniqid();
}
public function handle() {
return $this->_handle;
}
}
print( "UniqId = " . UniqId::get()->handle() . "\n" );
print( "UniqId = " . UniqId::get()->handle() . "\n" );
print( "UniqId = " . UniqId::get()->handle() . "\n" );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment