/**
* 生成32位以上唯一字符串ID
* @param int $length 不含前缀的长度,最小14,建议16+
* @param string $prefix 前缀
* @return string
*/
function unique_id($length = 32, $prefix = ''){
$only = $prefix;
$addLength = $length - 13;
$only .= uniqid();
if (function_exists('random_bytes')) {
$only.= substr(bin2hex(random_bytes(ceil(($addLength) / 2))),0,$addLength);
} elseif (function_exists('openssl_random_pseudo_bytes')) {
$only.= substr(bin2hex(openssl_random_pseudo_bytes(ceil($addLength / 2))),0,$addLength);
} else {
$only.= mt_rand(1*pow(10,($addLength)),9*pow(10,($addLength)));
}
return $only;
}