note 57150 deleted from function.uniqid by bjori

From: Date: Tue, 11 Apr 2006 20:58:47 +0000
Subject: note 57150 deleted from function.uniqid by bjori
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-107808@lists.php.net to get a copy of this message
Note Submitter: david dot dawkins at gmail dot com ---- Based on this page, I wrote this and since it's what I was looking for in the first place, I thought I'd share it. It's my first bit of PHP code, so all feedback is very welcome: <?php class Guid { var $guidText; function Guid() { $s = strtoupper(md5(uniqid(rand(),true))); $this->$guidText = substr($s,0,8) . '-' . substr($s,8,4) . '-' . substr($s,12,4). '-' . substr($s,16,4). '-' . substr($s,20); } function toString() { return $this->$guidText; } function NewGuid() { $g = new Guid(); return $g->toString(); } } echo "New guid: " . Guid::NewGuid() . "\n"; ?>

« previous php.notes (#107808) next »