php生成短域名函数
public function createRandCode($string) {
$code = '';
$hex_code = '1qaz2wsx3edc4rfv5t-gb6yhn7ujm8ik9ol0p_';
$now = microtime(true) * 10000;
$strlen = strlen($hex_code);
$hash_code = hash('sha256', $string);
// 这里会为编码定义一个随机的长度,长度取决于step
$step = rand(8, 16);
$count = ceil(strlen($hash_code) / $step);
for($i = 0; $i < $count; $i++) {
$start = $i * $step;
$hex_num = substr($hash_code, $start, $step);
$num = 0x3fffffff & (1 * '0x' . $hex_num);
$n = $num % $strlen;
$code .= $hex_code[$n];
}
return $code;
}
以上所述就是本文给大家分享的代码的全部内容了,希望大家能够喜欢。
直接上传到一个php空间就可以运行,但要装zend optimizer 3.3.0或以上版本,不需要mysql数据库,这个是access数据库免费的。。初次运行请到后台设置基本信息!默认是:http://localhost/xqcms3.1后台用户密码:创始人:admin admin后台登录地址:http://你的域名/admin.php3.1主要更新:1.优化了静态页面生成速度2.更改了系统后
0
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号