//随机手机号function randphone(){$arr = array(130,131,132,133,134,135,136,137,138,139, 144,147, 150,151,152,153,155,156,157,158,159, 176,177,178, 180,181,182,183,184,185,186,187,188,189, ); return $arr[mt_rand(0, (count($arr)-1))].mt_rand(1000, 9999).mt_rand(1000, 9999);}
<?php/*PHP实现的敏感词过滤方法*//**@todo 敏感词过滤,返回结果@param array $list 定义敏感词一维数组@param string $string 要过滤的内容@return string $log 处理结果 */function sensitive($list, $string){$count = 0; //违规词的个数 $sensitiveWord = ''; //违规词 $stringAfter = $string; //替换后的内容 $pattern = "/".implode("|",$lis...
/**根据出生日期计算 年龄/生肖/星座@param $birth 日期格式的年月日,例:'1999-11-15'@param $symbol 用什么符号分割,例:'-'@return $data 返回数据 */function birthday($birth, $symbol='-'){// 把数组中的值赋给变量 list($birth_year, $birth_month, $birth_day) = explode($symbol, $birth); // 计算年龄 $now_month = date('n'); // 当前月份,不带前导0 $now_day = date('j')...
/**获取最近七天所有日期@param string $time@param string $format@return array*/ function get_weeks($time = '', $format='Y-m-d'){ $time = $time != '' ? $time : time(); //组合数据 $date = []; for ($i=1; $i<=7; $i++){ $date[$i] = date($format ,strtotime( '+' . $i-7 .' days', $time)); } return...
<?php//200 正常状态 header('HTTP/1.1 200 OK'); // 301 永久重定向,记得在后面要加重定向地址 Location:$url header('HTTP/1.1 301 Moved Permanently'); // 重定向,其实就是302 暂时重定向 header('Location: http://www.maiyoule.com/'); // 设置页面304 没有修改 header('HTTP/1.1 304 Not Modified'); // 显示登录框, header('HTTP/1.1 401 ...
public function down_images() {//下载图片的链接$url = 'http://qr.liantu.com/api.php?text=https://www.girlsf.com/frontend/public/index.php/subject/personal/index'; $header = array("Connection: Keep-Alive", "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8", &...
/**友好的时间显示 *@author yhm *@param int $sTime 待显示的时间@param string $type 类型. normal | mohu | full | ymd | other@param string $alt 已失效 *@return string */function friendly_date($sTime, $type = 'normal', $alt = 'false'){if (!$sTime) return ''; //sTime=源时间,cTime=当前时间,dTime=时间差 $cTime = time(); $dTime = $...
function post_url($url, $data){$curl = curl_init(); // 启动一个CURL会话 curl_setopt($curl, CURLOPT_URL, $url); // 要访问的地址 curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE); // 对认证证书来源的检查 curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE); // 从证书中检查SSL加密算法是否存在 curl_setopt($curl, CURLOPT_USERAGENT, 'Mozill...
//冒泡排序(数组排序) function bubble_sort($array) { $count = count($array); if ($count <= 0) return false; for($i=0; $i<$count; $i++){ for($j=$count-1; $j>$i; $j--){ if ($array[$j] < $array[$j-1]){ $tmp = $array[$j]; $array[$j] = $array[$j-1]; ...
/**$list [array] 原始数组$pk [string] id$pid [string] 父级pid$child [array] 承载子集的容器return [array] 返回树结构**/function list_to_trees($list, $pk='id', $pid = 'pid', $child = 'listArea', $root = 0) { //创建Tree $tree = array(); if (is_array($list)) { //创建基于主键的数组引用 $refer = array(); foreach ($list as $key...
/** * 模拟POST提交 * @param string $url 地址 * @param string $data 提交的数据 * @return string 返回结果 */ function post_url($url, $data) { $curl = curl_init(); // 启动一个CURL会话 curl_setopt($curl, CURLOPT_URL, $url); // 要访问的地址 curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE); // 对认证证书来源的检查 cur...