I'm trying to create an API which generate guid. My php work perfectly on windows with wampp but it doesn't work on apache2 on my ubuntu server...
What's wrong?
$key = 0;
if (function_exists('com_create_guid')){
$key = trim(com_create_guid(), "{}");
}else{
mt_srand((double)microtime()*10000);//optional for php 4.2.0 and up.
$charid = strtoupper(md5(uniqid(rand(), true)));
$hyphen = chr(45);// "-"
$key = substr($charid, 0, 8).$hyphen
.substr($charid, 8, 4).$hyphen
.substr($charid,12, 4).$hyphen
.substr($charid,16, 4).$hyphen
.substr($charid,20,12);
}
$mail = $_GET['mail'];
$nom = $_GET['nom'];
$prenom = $_GET['prenom'];
if($mail && $nom && $prenom){
$retour = sendMail($mail, $nom, $key);
}else{
$retour = false;
}
EDIT:
I need use this:
bin2hex(openssl_random_pseudo_bytes(16));
This isn't the same format but it works!