php 截取字符串摘要

function cSubStr( $str, $len, $flag = true) { if(mb_strlen($str) < $len) return $str; $i = 0; $tlen = 0; $tstr = ''; while ( $tlen < $len ) { $tlen++; $ch

- 阅读全文 -

php 判断是否为AJAX请求

function isAjax($isPost = true) { if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && ($_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest')) { if ($isPost) { return (isse

- 阅读全文 -

php 生成唯一标识

function uuid( $more = true, $admin = false ) { if ( $more ) { return uniqid( md5( mt_rand() ), true ); } else { if ( $admin ) return uniqid( "zzz", false

- 阅读全文 -

php 判断手机号

function isMobile($mobile) { $pattern = "/^1[0-9]{10}$/"; if (preg_match($pattern,$mobile)){ return true; } return false; }

- 阅读全文 -

php token生成

function token($prefix = "") { $str = md5(uniqid(mt_rand(), true)); $_id = substr($str, 0, 8) . '-'; $_id .= substr($str, 8, 4) . '-'; $_id .= substr($str, 12, 4) . '-';

- 阅读全文 -

php 密码盐值生成

//加密用户密码、加盐值 function getPassword($pwd, $salt) { return md5($pwd."#".PASSWORD_KEY."#".$salt); // 摘要算法md5 } function getSalt() { $salt = rand(10000000,99999999); return

- 阅读全文 -

php 构建curl请求

function httpCurl($url, $type = 'GET', $param = array()) { $type = strtoupper($type); $ch = curl_init($url); curl_setopt($ch,CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_FO

- 阅读全文 -

php 根据身份证号获取生日

// 根据身份证号获取生日 function getBirthdayByIDNo($idcard) { $idCardLength = strlen(trim($idcard)); // 15位身份证验证生日,转换为18位 if ($idCardLength == 15) { $sBirthday = '19'.substr($idcard,6,2)

- 阅读全文 -

php 根据生日计算年龄

// 根据出生日期求年龄 function getAgeByBirthday($val = "") { if($val == "") { return 45; } $tYear = date('Y'); $tMonth = date('m'); $tDay = date('d'); $year

- 阅读全文 -

热门文章

最新文章

分类

其它