RE: [PHP-WIN] A uniqe ID for every item
| From: | Svensson, B.A.T. | Date: | Thu, 16 Aug 2001 14:22:10 +0000 |
| Subject: | RE: [PHP-WIN] A uniqe ID for every item | ||
| Groups: | php.windows | ||
| Request: | Send a blank email to php-windows+get-8902@lists.php.net to get a copy of this message | ||
>Hi all
>How can generate a uniqe id for every object of a class,
>for example
>
A very simple (untested) example could be:
int UniqueNumer(void)
{
static int nUniqueKey = 0;
return ++nUniqueKey;
}
>class A
>{
> var $id;
> function A()
> {
> $this->id = UniqueNumer();
> }
>}
It could be help full to know why you need to
create a unique number? Is it for ex only for naming
temporary files? Or should the uniqueness persist
over time?