随笔分类 -  php

posted @ 2019-03-19 15:18 宁佳兵 阅读(1568) 评论(0) 推荐(0) 编辑
摘要:/** * 获取天气 */ function get_tq () { //获取用户ip地址 $ip = get_real_ip(); // $ip = '123.125.71.38'; //根据ip地址 获取用户所在城市 $api_key = '8d6c8b8f3749aed6b... 阅读全文
posted @ 2019-03-14 14:42 宁佳兵 阅读(444) 评论(0) 推荐(0) 编辑
摘要:/** * 多维数组排序 * * @access public * @param array $arrays 多维数组 * @param string $sort_key 排序字段 * @param striny $sort_order 排列顺序 * @param string $sort_type 排序类型 ... 阅读全文
posted @ 2019-03-14 14:36 宁佳兵 阅读(590) 评论(0) 推荐(0) 编辑
摘要:function is_serialized( $data ) { $data = trim( $data ); if ( 'N;' == $data ) return true; if ( !preg_match( '/^([adObis]):/', $data, $badions ) ) ... 阅读全文
posted @ 2019-02-21 15:46 宁佳兵 阅读(1738) 评论(0) 推荐(0) 编辑
摘要:/** * 生成随机字符串 * @author 宁佳兵 * @param int $length * @return string */ function createNonceStr($length = 16) { $chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; $... 阅读全文
posted @ 2019-01-19 11:24 宁佳兵 阅读(976) 评论(0) 推荐(0) 编辑
摘要:首先在入口文件index.php得的当前目录下 创建 .htaccess文件。 然后将下面一段代码放进去; 【使用这种方式,首先要确认apache是否开启mod_rewrite 功能】 阅读全文
posted @ 2019-01-09 11:06 宁佳兵 阅读(239) 评论(0) 推荐(0) 编辑
摘要:/** * 获取某目录下所有文件 (递归次数限制10次, 以免产生性能瓶颈) * * @param string 目录 * @param array 获取的所有文件 * @return void 结果直接传递给第二个参数 * @author 宁佳兵 <meilijing.ning@foxmail.c 阅读全文
posted @ 2019-01-09 11:04 宁佳兵 阅读(1631) 评论(0) 推荐(0) 编辑
摘要:/** * 把返回的数据集转换成Tree * @param array $list 要转换的数据集 * @param string $pid parent标记字段 * @param string $level level标记字段 * @return array */ function list_to_tree($list, $pk='id', $pid = 'pid', $child... 阅读全文
posted @ 2019-01-09 11:00 宁佳兵 阅读(212) 评论(0) 推荐(0) 编辑
摘要:/** * 字符串截取,支持中文和其他编码 * @static * @access public * @param string $str 需要转换的字符串 * @param string $start 开始位置 * @param string $length 截取长度 * @param string $charset 编码格式 * @param string $suffix 截... 阅读全文
posted @ 2018-12-19 14:42 宁佳兵 阅读(339) 评论(0) 推荐(0) 编辑
摘要:防止SQL注入 对于WEB应用来说,SQL注入攻击无疑是首要防范的安全问题,系统底层对于数据安全方面本身进行了很多的处理和相应的防范机制,例如: $User = M("User"); // 实例化User对象 $User->find($_GET["id"]); 即便用户输入了一些恶意的id参数,系统 阅读全文
posted @ 2018-11-29 15:59 宁佳兵 阅读(141) 评论(0) 推荐(0) 编辑
摘要:windowsPHP扩展下载地址:https://windows.php.net/downloads/pecl/releases/ 阅读全文
posted @ 2018-06-08 15:57 宁佳兵 阅读(616) 评论(0) 推荐(0) 编辑
摘要:function isMobile(){ // 如果有HTTP_X_WAP_PROFILE则一定是移动设备 if (isset ($_SERVER['HTTP_X_WAP_PROFILE'])) return true; //此条摘自TPM智能切换模板引擎,适合TPM开发 if(isset ($_S 阅读全文
posted @ 2018-06-07 14:12 宁佳兵 阅读(497) 评论(0) 推荐(1) 编辑
摘要:public function getImage($url,$filename='') { if($url == ''){ return false; } if($filename == ''){ $ext = pathinfo($url); if($ext['extension'] != "jpg 阅读全文
posted @ 2018-05-16 13:54 宁佳兵 阅读(1284) 评论(0) 推荐(0) 编辑
摘要:/** * 是否为合法的身份证(支持15位和18位) * @param string $card * @return boolean */ function is_card($card) { if (preg_match('/^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\ 阅读全文
posted @ 2018-05-16 13:52 宁佳兵 阅读(232) 评论(0) 推荐(0) 编辑
摘要:/*发送邮件方法 *@param $to:接收者 $title:标题 $content:邮件内容 *@return bool true:发送成功 false:发送失败 */ function sendMail($to,$title,$content){ //引入PHPMailer的核心文件 vend 阅读全文
posted @ 2018-05-16 13:46 宁佳兵 阅读(213) 评论(0) 推荐(0) 编辑
摘要:/** * 无限极分类 * @param $arr 所有分类 * @param $pid * @param $step * @return array */ public function getTree($arr,$pid,$step){ global $tree; foreach($arr as 阅读全文
posted @ 2018-05-16 13:45 宁佳兵 阅读(1166) 评论(0) 推荐(0) 编辑
摘要:/** * 跳转方法 * @param $msg * @param null $path * @param null $parent */ public function alert($msg,$path=NULL,$parent=NULL){ if($parent true){ $str=<<<s 阅读全文
posted @ 2018-05-16 10:36 宁佳兵 阅读(160) 评论(0) 推荐(0) 编辑
摘要:/** * 生成原始的二维码(生成图片文件) * @param int $level * @param int $size */ public function qrcode($level=8,$size=8){ Vendor('phpqrcode.phpqrcode'); $errorCorrec 阅读全文
posted @ 2018-05-16 10:32 宁佳兵 阅读(249) 评论(0) 推荐(0) 编辑
摘要:后台:public function share() { $appId = C("WX_APPID"); //appid $appSecret = C("WX_APPSECRET");// 秘钥 $curl = "https://api.weixin.qq.com/cgi-bin/token?gra 阅读全文
posted @ 2017-11-27 18:04 宁佳兵 阅读(716) 评论(0) 推荐(0) 编辑
摘要:public function get_cookie(){ header("Content-type:text/html;Charset=utf8"); $ch =curl_init(); curl_setopt($ch,CURLOPT_URL,'爬取网址'); $header = array(); 阅读全文
posted @ 2017-11-07 11:26 宁佳兵 阅读(297) 评论(0) 推荐(0) 编辑
摘要:<?php function getIPLoc_QQ($queryIP){ $url = 'http://ip.qq.com/cgi-bin/searchip?searchip1='.$queryIP; $ch = curl_init($url); curl_setopt($ch,CURLOPT_E 阅读全文

点击右上角即可分享
微信分享提示