摘要:一.安装1.查看php命令是否可用php -v 如果有信息证明PHP安装好了,而且可用2.在命令行下进行framework目录中php yiic.php webapp ../cms二.使用1.修改默认控制器在应用名/protected/config/main.php中的数组中加入'defaultController'=>'Index', # 默认控制器2.取得应用程序的相对URL 如 /blog 格式Yii::app()->request->baseUrl例:request->baseUrl; ?>/assets/web/css/i
阅读全文
随笔分类 - PHP
PHP相关
摘要:total_page-$this->pageNum,($this->currentPage-ceil($this->pageNum/2)))); $end = min($this->total_page,$start+$this->pageNum); for ($i=$start;$icurrentPage){ $pagelist[$i]['url'] = ''; $pagelist[$i]['str'] = $i; continue; } $pagelist[$i]['url'] =...
阅读全文
摘要:/** * 文件尺寸转换,将大小将字节转为各种单位大小 * @param int $bytes 字节大小 * @return string 转换后带单位的大小 */ function tosize($bytes) { //自定义一个文件大小单位转换函数 if ($bytes >= pow(2,40)) { //如果提供的字节数大于等于2的40次方,则条件成立 $return = round($bytes / ...
阅读全文
摘要:一.Memcacheget($id); if($out === false || $out == null){ return ''; }else{ return $out; } } # 写入session public function write($id,$data) { $method = $data?'set':'replace'; return self::$handler->$method(self::session_key($id),$data...
阅读全文
摘要:width=$width; $this->height=$height; $this->codeNum=$codeNum; $this->checkCode=$this->createCheckCode(); $number=floor($width*$height/15); if($number > 240-$codeNum){ $this->disturbColorNum= 240-$codeNum; }else{ $this->disturbColorNum=$number; } } //通过访问该方法向浏览器中输出图像 functio...
阅读全文
摘要:0?$matches[0]:''; function CheckSubstrs($substrs,$text){ foreach($substrs as $substr) if(false!==strpos($text,$substr)){ return true; } return false; } $mobile_os_list=array('Google Wireless Transcoder','Windows CE',...
阅读全文
摘要:方法一:$arr = array('name'=> '丁三','age'=>29,'job'=>array( 'title'=>'经理', 'salary'=>8888, 'team'=>array('小红','小明','小华') ));functio...
阅读全文
摘要:// 发送邮件$phpmailer = new PHPMailer();$phpmailer->IsSMTP(); // 用smtp协议来发$phpmailer->Host = 'smtp.163.com';$phpmailer->SMTPAuth = true;$phpmailer->Username = '用户名';$phpmailer->Password = '密码';// 发信了$phpmailer->From = '发件人邮箱';$phpmailer->FromName =
阅读全文
摘要:function getURLToData($url){ $HTTP_Server = $url; $ch = curl_init(); curl_setopt ($ch,CURLOPT_URL,$HTTP_Server); curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,30); curl_setopt($ch,CURLOPT_USERAGENT,"Mozilla/5.0 (Linux; U; Android 4.1.1; zh-cn; MI...
阅读全文
摘要:/** * 获取客户端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 !== NULL) return $ip[$type]; if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) { $arr = explode(',', ...
阅读全文
摘要:conn($url); $this->setHeader('Host: '.$this->url['host']); } //设置写请求行 private function setLine($method){ $this->line[0] = $method. ' '.$this->url['path'].'?'.$this->url['query'].' '.$this->ver; } //设置写头信息 public function setHe
阅读全文
摘要:伪造IP和来源 function getClientIp() { if (!empty($_SERVER["HTTP_CLIENT_IP"])) $ip = $_SERVER["HTTP_CLIENT_IP"]; else if (!empty($_SERVER["HTTP_X_FORWARDED_
阅读全文
摘要:'; if(is_dir($path.'/'.$dir)){ recDir($path.'/'.$dir,$level+1); } } closedir($dh);}#recDir('./pmd/');// 递归创建目录function ...
阅读全文
摘要:1 $arr[$j]){25 $tmp = $arr[$i];26 $arr[$i] = $arr[$j];27 $arr[$j] = $tmp;28 }29 }30 }31 32 33 34 35 print_r($arr);$arr = array(20,11,18,33,17,32,15,22,13,25,36,16,66);function qSort($arr){ if(!is_array($arr) || empty($arr)) return array(); # 获取数...
阅读全文

浙公网安备 33010602011771号