php 将UNICODE编码后的内容进行解码

php 将UNICODE编码后的内容进行解码

function unicode_decode($name){// 转换编码,将Unicode编码转换成可以浏览的utf-8编码 $pattern = '/([\w]+)|(\\\u([\w]{4}))/i'; preg_match_all($pattern, $name, $matches); if (!empty($matches)) { $name = ''; for ($j = 0; $j < count($matches[0]); $j++) { $str = $matches[0][$j]; if (strpos(...

PHP 2019-12-11 PM 1715℃ 0条
php 遍历文件夹下的所有文件

php 遍历文件夹下的所有文件

/**$data 文件夹路径**/function list_file($date){ $fileArr = []; //1、首先先读取文件夹 $temp=scandir($date); //遍历文件夹 foreach($temp as $v){ $a=$date.'/'.$v; if(is_dir($a)){//如果是文件夹则执行 if($v=='.' || $v=='..'){//判断是否为系统隐藏的文件.和.. 如果是则跳过否则就继续往下走,防止无限循环再这里。 continue; } //echo "<...

PHP 2019-12-11 PM 2777℃ 0条
php验证邮箱格式

php验证邮箱格式

/**验证邮箱格式@param $email 邮箱@return bool */function is_email($email) {$chars = "/^[0-9a-zA-Z]+(?:[\_\.\-][a-z0-9\-]+)*@[a-zA-Z0-9]+(?:[-.][a-zA-Z0-9]+)*\.[a-zA-Z]+$/i"; if (preg_match($chars, $email)) { return true; } else { return false; }}

PHP 2019-12-11 PM 1852℃ 0条
php将内容进行UNICODE编码

php将内容进行UNICODE编码

function unicode_encode($name){$name = iconv('UTF-8', 'UCS-2', $name); $len = strlen($name); $str = ''; for ($i = 0; $i < $len - 1; $i = $i + 2) { $c = $name[$i]; $c2 = $name[$i + 1]; if (ord($c) > 0) { // 两个字节的文字 $str .= '\u'.base_convert(ord($c), 10, 16).base_co...

PHP 2019-12-11 PM 1692℃ 0条
php 格式化字节大小

php 格式化字节大小

/**格式化字节大小@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(...

PHP 2019-12-11 PM 1733℃ 0条
php创建目录

php创建目录

//创建目录function makedir($base_path = '') {//判断路径是否存在 if (!is_dir ( $base_path )) { mkdir ( $base_path, 0777, TRUE ); }}

PHP 2019-12-11 PM 1624℃ 0条
php获取两个日期之间的所有日期

php获取两个日期之间的所有日期

/**获取两个日期之见的所有日期*/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;}

PHP 2019-12-11 PM 2638℃ 0条
php创建指定长度的字符串

php创建指定长度的字符串

/**@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;}

PHP 2019-12-11 PM 1714℃ 0条
php 判断日期是当天

php 判断日期是当天

/**判断日期是当天@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;}

PHP 2019-12-11 PM 2255℃ 0条
php正则检测手机号码格式

php正则检测手机号码格式

/**正则检测手机号码格式**/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);}

PHP 2019-12-11 PM 2658℃ 0条
php根据用户uuid获取token

php根据用户uuid获取token

/** * 根据用户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...

PHP 2019-12-11 PM 2913℃ 0条