输出openssl_random_pseudo_bytes
php 函数不可读的字符。
我使用这个函数来生成一个唯一的字符串。
<?php
header('content-type:text/plain ; charset=utf-8');
$uniqid=openssl_random_pseudo_bytes(30 );
echo $uniqid ;
?>
输出如下内容:
#~�p�x�6�;g�ic�-z"���:i�
输出openssl_random_pseudo_bytes
php 函数不可读的字符。
我使用这个函数来生成一个唯一的字符串。
<?php
header('content-type:text/plain ; charset=utf-8');
$uniqid=openssl_random_pseudo_bytes(30 );
echo $uniqid ;
?>
输出如下内容:
#~�p�x�6�;g�ic�-z"���:i�
我必须使用 bin2hex() 函数。
<?php
$uniqid=bin2hex(openssl_random_pseudo_bytes(30 ));
echo $uniqid ;
?>
也这个功能肯定不会产生 uniqid 。
PHP中有类似uniqid函数的东西
你可以试试这个:
<?php
printf("uniqid(): %s\r\n", uniqid());echo '<br>';
printf("uniqid('php_'): %s\r\n", uniqid('php_'));echo '<br>';
printf("uniqid('', true): %s\r\n", uniqid('', true));echo '<br>';
?>
参考: http: //php.net/manual/en/function.uniqid.php