随笔分类 - PHP
摘要:[nginx]Step 1Download the shell scriptwget https://raw.github.com/JasonGiedymin/nginx-init-ubuntu/master/nginx -O /etc/init.d/nginxStep 2chmod +x /etc...
阅读全文
摘要:When usingrabbitmq,$this->conn = new AMQPConnection($conn_args);$this->conn->connect();i got these errorsPHP Fatal error: Class 'AMQPConnection' not foundHere is the way to resolve it.1. Install thelibrabbitmq library # Download the rabbitmq-c library @ version 0-9-1 git clone git:/
阅读全文
摘要:ubuntu12.10以后,默认的deb安装库上面的php版本已经是5.4了,公司的项目使用5.4的时候,还是会出现很多问题,所以不得不降级安装5.3顺便说一句,我原来的环境是nginx + php5.4 + mysql 的,现在只是把php5.4降级到php5.3,其它的不修复。新建一个叫做down_to_php53.sh,然后复制下面代码进去#!/bin/bash# # Original for 5.3 by Ruben Barkow (rubo77) http://www.entikey.z11.de/# release 1 PHP5.4 to 5.3 by Emil Terziev (
阅读全文
摘要:其它的代码就不贴了,直接上关键代码:$objPHPExcel = new PHPExcel();$objPHPExcel->setActiveSheetIndex(0);$objActSheet = $objPHPExcel->getActiveSheet();$objDrawing = new PHPExcel_Worksheet_Drawing();$objDrawing->setName('avatar');$objDrawing->setDescription('avatar');$objDrawing->setPath(‘
阅读全文
摘要:Mark一下,其实方法很简单$xml = json_decode(json_encode((array) simplexml_load_string($string)), 1);
阅读全文
摘要:1. 先到微信公众平台注册帐号http://mp.weixin.qq.com2. 下载demo微信公众平台提供了一个十分“朴素”的demo,说明如何调用消息接口的。代码真的很朴素,具体内容可到官网下载。3. 按照Yii的规则,做一个extension。这里命名为 weixin,目录结构如下:▾ extensions/ ▾ weixin/ Weixin.php*Weixin.php代码内容:<?php/** * WeixinCallback * * @package * @version $id$ * @copyright 1997-2005 The PHP Group * @...
阅读全文
摘要:php版本davidhhuan@davidhhuan-ThinkPad-T410:~$ php -versionPHP 5.3.10-1ubuntu3.4 with Suhosin-Patch (cli) (built: Sep 12 2012 18:59:41) Copyright (c) 1997-2012 The PHP GroupZend Engine v2.3.0, Copyright (c) 1998-2012 Zend TechnologiesYii版本1.1.13Yii Framework使用spl_autoload_register实现类的自动加载,这个很大的方便我们不用每次
阅读全文
摘要:原文地址:http://www.qttc.net/201206105.htmlfunction urlShort($url){ $url= crc32($url); $result= sprintf("%u", $url); $sUrl= ''; while($result>0){ $s= $result%62; if($s>35){ $s= chr($s+61); } elseif($s>9 && $s<=35){ $s= chr($s+ 55); } $...
阅读全文
摘要:when i using$command = Yii::app()->db->createCommand(" SELECT * FROM vote v LEFT JOIN works w ON w.id = v.works_id LEFT JOIN activity a ON a.id = w.activ...
阅读全文
摘要:When developing distributed applications with Yii, naturally, we will face that we have toshare the session in different machine. So here we will use memcache to do it.here is the example to store the session with memcache in Yii, in the main.php file: 'cache'=>array('class'=>&
阅读全文
摘要:date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function.出现这个问题,主要是因为没有在 php.ini 里面对时区进行设置造成的,解决方法是,修改 php.ini,加入:date.timezone="Asia/Chongqing"重启 apache,搞掂!
阅读全文
摘要:情景一,通过 define 定义全局常量//首先定义了一个叫做MAXSIZE的常量define("MAXSIZE",100);//定义一个变量,它的值就是'MAXSIZE'这个字符串$str='MAXSIZE';//通过输出$str这个变量可以得到100这个值echoconstant($str);情景二,类或者接口里面通过 const 定义的常量interfacebar{consttest='foobar!';}classfoo{consttest='foobar!';}$const='test'
阅读全文
摘要:再谈Yii Framework中的事件event,我写过的关于Yii事件event的另一篇文章[Yii Framework] Yii中事件和行为的区别和应用 http://www.cnblogs.com/davidhhuan/archive/2012/01/19/2326123.html假设有类MyComponent,它是继承于CComponent,通过查看 CComponent 的 __set() 方法,publicfunction__set($name,$value){$setter='set'.$name;if(method_exists($this,$setter))r
阅读全文
摘要:This article comes fromhttp://www.yiiframework.com/wiki/155/the-directory-structure-of-the-yii-project-siteOverall StructureTop-level DirectoriesApplication DirectoriesThe Common DirectoryApplication ConfigurationsPath AliasDeploymentLinksIn this article, we describe the directory structure used by
阅读全文
摘要:这里假设我们要建立 中文/英文 切换的站点1. 设置全局默认的语言文件添加代码:protected/config/main.php'language'=>'zh_cn',2. 控制器根据用户选择动态切换语言一般来说,我们所有的控制器都是继承于 protected/components/Controller.php 这个类。因此,我们可以在这个类里面进行语言的定义来影响当前的请求。publicfunctioninit(){if(isset($_GET['lang'])&&$_GET['lang']!="
阅读全文
摘要:It is very easy to generate phpdoc in NetBeans, just follow these steps, and you will see the amazing things :)Step 1: Download the PhpDoc:http://www.phpdoc.org/Step 2:Extract the file you downloaded.Step 3:Launch the Netbeans. Tools -> Options, see the details in the image below: Remember to cha
阅读全文
摘要:As we know, in PHP, we can use session_encode() and session_decode() to encode/decode the session data, but, if you have tried these twofunctionality, you will see the they are not going as you think. So here, i find these two functionality which will help you to do that. /***serializesession**@par.
阅读全文
摘要:As we know, when using netbeans, it will scan the project automaticly by itself, at this time, it will slow down the system. Also, when adding a file to the project folder (not via NetBeans but you do it in the folder), you have to close NetBeans to refresh the project files for the reason that you
阅读全文
摘要:Let say you installed PHP and run it for a month, but now you want to use curl in PHP.But so bad that you didn't install this extension when you installed PHP. That is to say, now you want to add PHP extension. Here is an example to install curl extension.apache2 is in/usr/local/apache2php is in
阅读全文
摘要:这里用到了jquery的ajax。页面: $.ajax({type:'POST',url:'http://www.yourwebsite.com',beforeSend:function(XMLHttpRequest){XMLHttpRequest.setRequestHeader("request_type","ajax");},data:'test=test',success:function(rs){alert('ok');}}});PHP代码:echoisset($_SERVER[&
阅读全文

浙公网安备 33010602011771号