note 59951 deleted from function.uniqid by bjori

From: Date: Tue, 11 Apr 2006 20:59:41 +0000
Subject: note 59951 deleted from function.uniqid by bjori
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-107810@lists.php.net to get a copy of this message
Note Submitter: php at REMOVEMEkennel17 dot co dot uk ---- Actually, david dot dawkins' class was correctly implemented. As you can see, the NewGuid() function is used to get a Guid statically, which is likely to be the most common use. (However, I would suggest that creating a class as a wrapper for a single function is overkill.) It should also be noted that the code provided by dyer85 is incorrect. Firstly, you cannot return a value from a constructor. Secondly, the first line of the toString() function assigns a value to $str by reference. It should be assigned by value, otherwise the strtolower()/strtoupper() functions will affect the stored value, and each subsequent call will add extra separators to the output string. The first line of toString() should therefore be: $str = $this->guidText; Finally, the toString() function should not encode the html entities in the returned value, as in most cases (DB storage, file handling, session ids, etc.) the unencoded form of the Guid will be required.

« previous php.notes (#107810) next »