文章分类 -  php封装函数

摘要:``` /** * 发送HTTP状态 * @param integer $code 状态码 * @return void */ function send_http_status($code) { static $_status = array( // Informational 1xx 100 => 'Continue', ... 阅读全文
posted @ 2017-06-13 15:22 oneboi 阅读(202) 评论(1) 推荐(0)
摘要:``` //https请求(支持GET和POST) function https_request($url, $data = null){ $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_SSL_VERIFYP... 阅读全文
posted @ 2017-06-13 15:15 oneboi 阅读(99) 评论(0) 推荐(0)
摘要:``` //对象转换为数组 function object_array($array) { if(is_object($array)) { $array = (array)$array; } if(is_array($array)) { foreach($array as $key=>$value) { $array[$key] = object_array($value); ... 阅读全文
posted @ 2017-06-13 15:13 oneboi 阅读(185) 评论(0) 推荐(0)
摘要:``` / 等比例绽放图片大小 / function drawImg($from,$w=100,$h=100,$newfile){ $info = getimagesize($from); switch ($info[2]){ case 1: $im = imagecreatefromgif($fr 阅读全文
posted @ 2017-06-13 15:10 oneboi 阅读(113) 评论(0) 推荐(0)
摘要:``` /** * 获取客户端IP地址 * @param integer $type 返回类型 0 返回IP地址 1 返回IPV4地址数字 * @return mixed */ function get_client_ip($type = 0) { $type = $type ? 1 : 0; static $ip = NULL; if ($ip !=... 阅读全文
posted @ 2017-06-13 15:09 oneboi 阅读(83) 评论(0) 推荐(0)
摘要:``` /** * 判断是否微信访问 */ function is_weixin(){ if(strpos($_SERVER['HTTP_USER_AGENT'],'MicroMessenger') !== false){ return true; }else{ return false; } } ``` 阅读全文
posted @ 2017-06-13 15:06 oneboi 阅读(86) 评论(0) 推荐(0)
摘要:``` /** * 判断是否手机访问 */ function is_mobile(){ if(preg_match('/(iphone|ipad|ipod|android)/i', strtolower($_SERVER['HTTP_USER_AGENT']))){ return true; }else{ return false; } ``` 阅读全文
posted @ 2017-06-13 15:05 oneboi 阅读(72) 评论(0) 推荐(0)
摘要:``` function datetime( $unix_time=null){ if($unix_time){ return date('Y-m-d H:i:s',$unix_time); }else{ return date('Y-m-d H:i:s',time()); } } ``` 阅读全文
posted @ 2017-06-13 15:02 oneboi 阅读(101) 评论(0) 推荐(0)
摘要:``` /** * URL重定向 * @param string $url 重定向的URL地址 * @param integer $time 重定向的等待时间(秒) * @param string $msg 重定向前的提示信息 * @return void */ function redirect($url, $time=0, $msg=''){ //多行URL地址支持 ... 阅读全文
posted @ 2017-06-13 14:58 oneboi 阅读(1588) 评论(0) 推荐(0)