This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 写入文件,超时则写入失败 | |
* | |
* @param mixed $fileName 文件名 | |
* @param mixed $text 要写入的内容 | |
* @param int $timeOut 等待锁的超时时间 | |
* @param string $mode 文件操作类型,同fopen的model参数一致 | |
* @return boolean | |
*/ | |
function swrite($fileName, $text, $timeOut = 1, $mode = 'a') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function CurentTime() | |
{ | |
var now = new Date(); | |
var year = now.getFullYear(); //年 | |
var month = now.getMonth() + 1; //月 | |
var day = now.getDate(); //日 | |
var hh = now.getHours(); //时 | |
var mm = now.getMinutes(); //分 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$code = createCode(1,6); | |
echo code2Id($code[0]); | |
/** | |
* 根据id获取一组随机字符串 | |
* | |
* @param mixed $batch_id | |
* @param mixed $num | |
* @access public | |
* @return void |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* 经典的概率算法, | |
* $proArr是一个预先设置的数组, | |
* 假设数组为:array(100,200,300,400), | |
* 开始是从1,1000 这个概率范围内筛选第一个数是否在他的出现概率范围之内, | |
* 如果不在,则将概率空间,也就是k的值减去刚刚的那个数字的概率空间, | |
* 在本例当中就是减去100,也就是说第二个数是在1,900这个范围内筛选的。 | |
* 这样 筛选到最终,总会有一个数满足要求。 | |
* 就相当于去一个箱子里摸东西, |