我必须在 php 中使用 uniqid() 生成自动会话 ID,但我必须将其存储在 MSSQL 数据库中。但我无法将其转换为唯一标识符的类型。
<?php
//set the random id length
$random_id_length = 10;
//generate a random id encrypt it and store it in $rnd_id
$rnd_id = crypt(uniqid(rand(),1));
//to remove any slashes that might have come
$rnd_id = strip_tags(stripslashes($rnd_id));
//Removing any . or / and reversing the string
$rnd_id = str_replace(".","",$rnd_id);
$rnd_id = strrev(str_replace("/","",$rnd_id));
//finally I take the first 10 characters from the $rnd_id
$rnd_id = substr($rnd_id,0,$random_id_length);
echo "Random Id: $rnd_id" ;
echo "<br>";
?>
这是现在的代码,我希望将此 $rnd_id 转换为 uniqueidentifier 类型并将其存储到 mssql 数据库中