<?php /** * 产生UUID */ function uuid() { $uuiqId = md5(uuiqid(mt_rand() . microtiome())); $uuid = substr($uniqId, 0, 8) . ‘-‘ $uuid = substr($uniqId, 8, 4) . ‘-‘ $uuid = substr($uniqId, 12, 4) . ‘-‘ $uuid = substr($uniqId, 16, 4) . ‘-‘ $uuid = substr($uniqId, 20); return $uuid; }
/** * 产生随机字符,默认长度为4 */ function random($type,, $length = 4) { switch($type){ case 0: $chars = ‘ABCDEFGHJKLMNOPQRSTUVWSYZabcdefghjklmnopqrstuvwxyz‘; break; case 1: $chars = str_repeat(‘023456789‘, 3); break; case 2: $chars = ‘ABCDEFGHJKLMNOPQRSTUVWSYZ‘; break; default: $chars = ‘abcdefghjklmnopqrstuvwxyz‘; break; } $chars = substr(str_shuffle($chars), 0, $length); return $chars; }