随笔分类 - php
php学习交流
摘要:/** * 实现中文字串截取无乱码的方法 */function getSubstr($string, $start, $length) { if(mb_strlen($string,'utf-8')>$length){ $str = mb_substr($string, $start, $lengt
阅读全文
摘要:/** * 检查手机号码格式 * @param $mobile 手机号码 */function check_mobile($mobile){ if(preg_match('/1[34578]\d{9}$/',$mobile)) return true; return false;} /** * 检查
阅读全文
摘要:function timediff($begin_time,$end_time) { if($begin_time < $end_time){ $starttime = $begin_time; $endtime = $end_time; } else{ $starttime = $end_time
阅读全文
摘要:function curlRequest($url, $data=array(), $method = 'GET'){ $method = strtoupper($method); $ch = curl_init(); curl_setopt($ch, CURLOPT_FAILONERROR, 1)
阅读全文
摘要:function createXmls($cars){ $xml = new DOMDocument(); $xml->formatOutput = TRUE; $xml->encoding = 'utf8'; $root = $xml->createElement('urlset'); if (c
阅读全文
摘要:public function actionImport() { //post请求过来的 $fileName = $_FILES['file']['name']; $fileTmpName = $_FILES['file']['tmp_name']; //判断是否选择了上传的文件 if (empty
阅读全文
摘要://获取当前来访用户的ip地址 function GetIp(){ $realip = ''; $unknown = 'unknown'; if (isset($_SERVER)){ if(isset($_SERVER['HTTP_X_FORWARDED_FOR']) && !empty($_SER
阅读全文
摘要:public function readFile($path){ $data = array(); $returnTxt = ''; // 初始化返回 $i = 1; $fh = fopen($path,"r"); while (!feof($fh)){ $line = fgets($fh, 409
阅读全文
摘要://解压tar.gz, gz public function unzip_gz($gz_file){ if(!strpos($gz_file,'.gz')){ return false; } $buffer_size = 4096; // read 4kb at a time if(strpos($
阅读全文
摘要:function getFile($url, $save_dir = '', $filename = '', $type = 0) { if (trim($url) == '') { return false; } if (trim($save_dir) == '') { $save_dir = '
阅读全文
摘要:function is_weixin() { if (strpos($_SERVER['HTTP_USER_AGENT'], 'MicroMessenger') !== false) { return true; } return false;}
阅读全文
摘要:/** * 判断当前访问的用户是 PC端 还是 手机端 返回true 为手机端 false 为PC 端 * @return boolean *//** * 是否移动端访问访问 * * @return bool */function isMobile(){ // 如果有HTTP_X_WAP_PROFI
阅读全文

浙公网安备 33010602011771号