易截截图软件、单文件、免安装、纯绿色、仅160KB

PHP UUID的生成源码

现在好多地方都用UUID,比如数据库的个自动的UUID
UUID结构如下(都为十六进制字符)
XXXXX
XXX-XXXX-XXXX-XXXX-XXXXXXXXXXX
研究其生成实现过程才发现,原来是这样的
1、提取当前时候值和时间戳
2、把这两个值转换成十六进制
3、取时间值和时间戳的前5和时间值的前六位
4、生成一个三位的十六进制,三个四位的十六进制和一个五位的十六进制
5、依据上面的结构组成UUID
PHP代码如下
function create_guid()
{
$microTime = microtime();
list($a_dec, $a_sec) = explode(" ", $microTime);
$dec_hex = dechex($a_dec* 1000000);
$sec_hex = dechex($a_sec);
ensure_length($dec_hex, 5);
ensure_length($sec_hex, 6);
$guid = "";
$guid .= $dec_hex;
$guid .= create_guid_section(3);
$guid .= '-';
$guid .= create_guid_section(4);
$guid .= '-';
$guid .= create_guid_section(4);
$guid .= '-';
$guid .= create_guid_section(4);
$guid .= '-';
$guid .= $sec_hex;
$guid .= create_guid_section(6);
return $guid;
}
function create_guid_section($characters)
{
$return = "";
for($i=0; $i<$characters; $i++)
{
$return .= dechex(mt_rand(0,15));
}
return $return;
}


相关文档:

PHP实现文件的读和写功能

进行文件的读和写,先打开一个文件,然后开始读或者写文件,最后再关系这个文件资源。
如,文件的读操作:
<?php
$file = fopen('your file path','r');
while(!feof($file)){ //当没有读取到文件结尾,继续循环读取操作
$line = fgets($file); //读取到一行的内容
echo $line.'<br/>';
}
fclose($file) ......

网站页面自动跳转实现方法PHP、JSP等


自动转向,也叫自动重定向。自动跳转,指当访问用户登陆到某网站时,自动将用户转向其它网页地址的一种技术。转向的网页地址可以是网站内的其它网页,也可以是其它网站。通常情况下,浏览器会收到一个网页,该页面含有自动加载一其它网页的代码。该页面有可能在服务器端被转换,这样的话,浏览器只收到一个页面,而自动转 ......

php中访问mysql的例子

<?php
        $mysql_server_name = "localhost";
        $mysql_username = "root";
        $mysql_password = "root";
        ......

PHP开发常见问题解决列表

PHP开发常见问题解决列表
1. 学习Zend Framework tutorial过程中的问题
(1)执行"zf create project zf-tutorial"出现如下错误:
     '"php.exe"' is not recognized as an internal or external command, operable program or batch file.
     解决办法:原因是因为php.ex ......

PHP网站开发方案(开发新人必读)


                 PHP网站开发方案(开发新人必读)
一、开发成员
a)项目主管
b)页面美工
c)页面开发
d)服务端程序开发
e)系统与数据管理
f)测试与版本控制
二、 网站组开发简明流程
三、 开发工具与环境
a)服务器配置
i. W ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号