note 59951 added to function.uniqid

From: Date: Wed, 21 Dec 2005 03:12:05 +0000
Subject: note 59951 added to function.uniqid
Groups: php.notes 
Request: Send a blank email to php-notes+get-100498@lists.php.net to get a copy of this message
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. ---- Manual Page -- http://www.php.net/manual/en/function.uniqid.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+59951 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+59951&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+59951&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+59951&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+59951&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+59951&report=yes&reason=non-english Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+59951&report=yes&reason=already+in+docs Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+59951&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+59951&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#100498) next »