/**格式化字节大小@param number $size 字节数@param string $delimiter 数字和单位分隔符@return string 格式化后的带单位的大小 */function format_bytes($size, $delimiter = '') {$units = array('B', 'KB', 'MB', 'GB', 'TB', 'PB'); for ($i = 0; $size >= 1024 && $i < 5; $i++) $size /= 1024; return round(...
//创建目录function makedir($base_path = '') {//判断路径是否存在 if (!is_dir ( $base_path )) { mkdir ( $base_path, 0777, TRUE ); }}
/**获取两个日期之见的所有日期*/function prDates($start,$end){ $dt_start = $start; $dt_end = $end; while ($dt_start<=$dt_end){ $pr_dates[] = date('Y-m-d',$dt_start)."\n"; $dt_start = strtotime('+1 day',$dt_start); if($dt_start==$end){ break; }} return $pr_dates;}
/**@param $codeLen 随机字符串长度@return string 随机字符串 */function randStr($codeLen){$str="abcdefghijkmnpqrstuvwxyz0123456789"; $rand=""; for($i=0; $i<$codeLen-1; $i++){ $rand .= $str[mt_rand(0, strlen($str)-1)]; //如:随机数为30 则:$str[30] } return $rand;}
/**判断日期是当天@param $time@return bool */function time_judge($time){// 截取日期部分,摒弃时分秒$result = substr($time, 0, 10);// 获取今天的日期,格式为 YYYY-MM-DD$date = date('Y-m-d');// 使用IF当作字符串判断是否相等if ($result == $date) { return true; } return false;}
/**正则检测手机号码格式**/public function checkMobileFormat($sMobile){$sPregMatch = '/^1(3[0-9]|4[57]|5[0-35-9]|7[0-9]|8[0-9])\d{8}$/';return preg_match($sPregMatch, $sMobile);}
/** * 根据用户uuid获取token * @param [type] $uuid [description] * @return [type] [description] */ public function getToken($uuid) { $v = $uuid; $key = mt_rand(); $hash = hash_hmac("sha1", $v . mt_rand() . time(), $key, true); $token = str_replace('=', '', base64_enco...
/** * curl模拟get/post提交 * @param $url 请求的url地址 * @param $data 发送的数据 * @param $type 请求的类型 * @return $result 返回的数据 */ function httpsRequest(String $url, $data = [], $type = "html"){ $curl = curl_init(); // 启动一个CURL会话 curl_setopt($curl, CURLOPT_URL, $url); // 要访问的地址 curl_se...
/**中文转阿拉伯@param $str@return float|int|mixed */function chrtonum($str){$num = 0; $bins = array("零", "一", "二", "三", "四", "五", "六", "七", "八", "九", 'a' => "个", 'b' => "十", 'c'...
/*** @param string $url 地址 */function get_url($url){ $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,$url); //设置访问的url地址 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);//不输出内容 ...
/**随机IP方法@param@return string $huoduan_ip 最终IP地址 */function rand_ip(){$ip_long = array( array('607649792', '608174079'), //36.56.0.0-36.63.255.255 array('975044608', '977272831'), //58.30.0.0-58.63.255.255 array('999751680', '999784447'), //59.151.0.0-59.151.127.255 ...