Zend Framework教程之响应对象的封装Zend_Controller_Response实例详解
本文实例讲述了ZendFramework教程之响应对象的封装Zend_Controller_Response用法。分享给大家供大家参考,具体如下:
概述
响应对象逻辑上是请求对象的搭档.目的在于收集消息体和/或消息头,因而可能返回大批的结果。
Zend_Controller_Response响应对象的基本实现
├──Response
│ ├──Abstract.php
│ ├──Cli.php
│ ├──Exception.php
│ ├──Http.php
│ └──HttpTestCase.php
Zend_Controller_Response_Abstract
abstractclassZend_Controller_Response_Abstract
{
/**
*Bodycontent
*@vararray
*/
protected$_body=array();
/**
*Exceptionstack
*@varException
*/
protected$_exceptions=array();
/**
*Arrayofheaders.Eachheaderisanarraywithkeys'name'and'value'
*@vararray
*/
protected$_headers=array();
/**
*Arrayofrawheaders.Eachheaderisasinglestring,theentireheadertoemit
*@vararray
*/
protected$_headersRaw=array();
/**
*HTTPresponsecodetouseinheaders
*@varint
*/
protected$_httpResponseCode=200;
/**
*Flag;isthisresponsearedirect?
*@varboolean
*/
protected$_isRedirect=false;
/**
*Whetherornottorenderexceptions;offbydefault
*@varboolean
*/
protected$_renderExceptions=false;
/**
*Flag;iftrue,whenheaderoperationsarecalledafterheadershavebeen
*sent,anexceptionwillberaised;otherwise,processingwillcontinue
*asnormal.Defaultstotrue.
*
*@seecanSendHeaders()
*@varboolean
*/
public$headersSentThrowsException=true;
/**
*Normalizeaheadername
*
*NormalizesaheadernametoX-Capitalized-Names
*
*@paramstring$name
*@returnstring
*/
protectedfunction_normalizeHeader($name)
{
$filtered=str_replace(array('-','_'),'',(string)$name);
$filtered=ucwords(strtolower($filtered));
$filtered=str_replace('','-',$filtered);
return$filtered;
}
/**
*Setaheader
*
*If$replaceistrue,replacesanyheadersalreadydefinedwiththat
*$name.
*
*@paramstring$name
*@paramstring$value
*@paramboolean$replace
*@returnZend_Controller_Response_Abstract
*/
publicfunctionsetHeader($name,$value,$replace=false)
{
$this->canSendHeaders(true);
$name=$this->_normalizeHeader($name);
$value=(string)$value;
if($replace){
foreach($this->_headersas$key=>$header){
if($name==$header['name']){
unset($this->_headers[$key]);
}
}
}
$this->_headers[]=array(
'name'=>$name,
'value'=>$value,
'replace'=>$replace
);
return$this;
}
/**
*SetredirectURL
*
*SetsLocationheaderandresponsecode.Forcesreplacementofanyprior
*redirects.
*
*@paramstring$url
*@paramint$code
*@returnZend_Controller_Response_Abstract
*/
publicfunctionsetRedirect($url,$code=302)
{
$this->canSendHeaders(true);
$this->setHeader('Location',$url,true)
->setHttpResponseCode($code);
return$this;
}
/**
*Isthisaredirect?
*
*@returnboolean
*/
publicfunctionisRedirect()
{
return$this->_isRedirect;
}
/**
*Returnarrayofheaders;see{@link$_headers}forformat
*
*@returnarray
*/
publicfunctiongetHeaders()
{
return$this->_headers;
}
/**
*Clearheaders
*
*@returnZend_Controller_Response_Abstract
*/
publicfunctionclearHeaders()
{
$this->_headers=array();
return$this;
}
/**
*ClearsthespecifiedHTTPheader
*
*@paramstring$name
*@returnZend_Controller_Response_Abstract
*/
publicfunctionclearHeader($name)
{
if(!count($this->_headers)){
return$this;
}
foreach($this->_headersas$index=>$header){
if($name==$header['name']){
unset($this->_headers[$index]);
}
}
return$this;
}
/**
*SetrawHTTPheader
*
*Allowssettingnonkey=>valueheaders,suchasstatuscodes
*
*@paramstring$value
*@returnZend_Controller_Response_Abstract
*/
publicfunctionsetRawHeader($value)
{
$this->canSendHeaders(true);
if('Location'==substr($value,0,8)){
$this->_isRedirect=true;
}
$this->_headersRaw[]=(string)$value;
return$this;
}
/**
*Retrieveall{@linksetRawHeader()rawHTTPheaders}
*
*@returnarray
*/
publicfunctiongetRawHeaders()
{
return$this->_headersRaw;
}
/**
*Clearall{@linksetRawHeader()rawHTTPheaders}
*
*@returnZend_Controller_Response_Abstract
*/
publicfunctionclearRawHeaders()
{
$this->_headersRaw=array();
return$this;
}
/**
*ClearsthespecifiedrawHTTPheader
*
*@paramstring$headerRaw
*@returnZend_Controller_Response_Abstract
*/
publicfunctionclearRawHeader($headerRaw)
{
if(!count($this->_headersRaw)){
return$this;
}
$key=array_search($headerRaw,$this->_headersRaw);
if($key!==false){
unset($this->_headersRaw[$key]);
}
return$this;
}
/**
*Clearallheaders,normalandraw
*
*@returnZend_Controller_Response_Abstract
*/
publicfunctionclearAllHeaders()
{
return$this->clearHeaders()
->clearRawHeaders();
}
/**
*SetHTTPresponsecodetousewithheaders
*
*@paramint$code
*@returnZend_Controller_Response_Abstract
*/
publicfunctionsetHttpResponseCode($code)
{
if(!is_int($code)||(100>$code)||(599<$code)){
require_once'Zend/Controller/Response/Exception.php';
thrownewZend_Controller_Response_Exception('InvalidHTTPresponsecode');
}
if((300<=$code)&&(307>=$code)){
$this->_isRedirect=true;
}else{
$this->_isRedirect=false;
}
$this->_httpResponseCode=$code;
return$this;
}
/**
*RetrieveHTTPresponsecode
*
*@returnint
*/
publicfunctiongetHttpResponseCode()
{
return$this->_httpResponseCode;
}
/**
*Canwesendheaders?
*
*@paramboolean$throwWhetherornottothrowanexceptionifheadershavebeensent;defaultstofalse
*@returnboolean
*@throwsZend_Controller_Response_Exception
*/
publicfunctioncanSendHeaders($throw=false)
{
$ok=headers_sent($file,$line);
if($ok&&$throw&&$this->headersSentThrowsException){
require_once'Zend/Controller/Response/Exception.php';
thrownewZend_Controller_Response_Exception('Cannotsendheaders;headersalreadysentin'.$file.',line'.$line);
}
return!$ok;
}
/**
*Sendallheaders
*
*Sendsanyheadersspecified.Ifan{@linksetHttpResponseCode()HTTPresponsecode}
*hasbeenspecified,itissentwiththefirstheader.
*
*@returnZend_Controller_Response_Abstract
*/
publicfunctionsendHeaders()
{
//Onlycheckifwecansendheadersifwehaveheaderstosend
if(count($this->_headersRaw)||count($this->_headers)||(200!=$this->_httpResponseCode)){
$this->canSendHeaders(true);
}elseif(200==$this->_httpResponseCode){
//Haven'tchangedtheresponsecode,andwehavenoheaders
return$this;
}
$httpCodeSent=false;
foreach($this->_headersRawas$header){
if(!$httpCodeSent&&$this->_httpResponseCode){
header($header,true,$this->_httpResponseCode);
$httpCodeSent=true;
}else{
header($header);
}
}
foreach($this->_headersas$header){
if(!$httpCodeSent&&$this->_httpResponseCode){
header($header['name'].':'.$header['value'],$header['replace'],$this->_httpResponseCode);
$httpCodeSent=true;
}else{
header($header['name'].':'.$header['value'],$header['replace']);
}
}
if(!$httpCodeSent){
header('HTTP/1.1'.$this->_httpResponseCode);
$httpCodeSent=true;
}
return$this;
}
/**
*Setbodycontent
*
*If$nameisnotpassed,orisnotastring,resetstheentirebodyand
*setsthe'default'keyto$content.
*
*If$nameisastring,setsthenamedsegmentinthebodyarrayto
*$content.
*
*@paramstring$content
*@paramnull|string$name
*@returnZend_Controller_Response_Abstract
*/
publicfunctionsetBody($content,$name=null)
{
if((null===$name)||!is_string($name)){
$this->_body=array('default'=>(string)$content);
}else{
$this->_body[$name]=(string)$content;
}
return$this;
}
/**
*Appendcontenttothebodycontent
*
*@paramstring$content
*@paramnull|string$name
*@returnZend_Controller_Response_Abstract
*/
publicfunctionappendBody($content,$name=null)
{
if((null===$name)||!is_string($name)){
if(isset($this->_body['default'])){
$this->_body['default'].=(string)$content;
}else{
return$this->append('default',$content);
}
}elseif(isset($this->_body[$name])){
$this->_body[$name].=(string)$content;
}else{
return$this->append($name,$content);
}
return$this;
}
/**
*Clearbodyarray
*
*Withnoarguments,clearstheentirebodyarray.Givena$name,clears
*justthatnamedsegment;ifnosegmentmatching$nameexists,returns
*falsetoindicateanerror.
*
*@paramstring$nameNamedsegmenttoclear
*@returnboolean
*/
publicfunctionclearBody($name=null)
{
if(null!==$name){
$name=(string)$name;
if(isset($this->_body[$name])){
unset($this->_body[$name]);
returntrue;
}
returnfalse;
}
$this->_body=array();
returntrue;
}
/**
*Returnthebodycontent
*
*If$specisfalse,returnstheconcatenatedvaluesofthebodycontent
*array.If$specisbooleantrue,returnsthebodycontentarray.If
*$specisastringandmatchesanamedsegment,returnsthecontentsof
*thatsegment;otherwise,returnsnull.
*
*@paramboolean$spec
*@returnstring|array|null
*/
publicfunctiongetBody($spec=false)
{
if(false===$spec){
ob_start();
$this->outputBody();
returnob_get_clean();
}elseif(true===$spec){
return$this->_body;
}elseif(is_string($spec)&&isset($this->_body[$spec])){
return$this->_body[$spec];
}
returnnull;
}
/**
*Appendanamedbodysegmenttothebodycontentarray
*
*Ifsegmentalreadyexists,replaceswith$contentandplacesatendof
*array.
*
*@paramstring$name
*@paramstring$content
*@returnZend_Controller_Response_Abstract
*/
publicfunctionappend($name,$content)
{
if(!is_string($name)){
require_once'Zend/Controller/Response/Exception.php';
thrownewZend_Controller_Response_Exception('Invalidbodysegmentkey("'.gettype($name).'")');
}
if(isset($this->_body[$name])){
unset($this->_body[$name]);
}
$this->_body[$name]=(string)$content;
return$this;
}
/**
*Prependanamedbodysegmenttothebodycontentarray
*
*Ifsegmentalreadyexists,replaceswith$contentandplacesattopof
*array.
*
*@paramstring$name
*@paramstring$content
*@returnvoid
*/
publicfunctionprepend($name,$content)
{
if(!is_string($name)){
require_once'Zend/Controller/Response/Exception.php';
thrownewZend_Controller_Response_Exception('Invalidbodysegmentkey("'.gettype($name).'")');
}
if(isset($this->_body[$name])){
unset($this->_body[$name]);
}
$new=array($name=>(string)$content);
$this->_body=$new+$this->_body;
return$this;
}
/**
*Insertanamedsegmentintothebodycontentarray
*
*@paramstring$name
*@paramstring$content
*@paramstring$parent
*@paramboolean$beforeWhethertoinsertthenewsegmentbeforeor
*aftertheparent.Defaultstofalse(after)
*@returnZend_Controller_Response_Abstract
*/
publicfunctioninsert($name,$content,$parent=null,$before=false)
{
if(!is_string($name)){
require_once'Zend/Controller/Response/Exception.php';
thrownewZend_Controller_Response_Exception('Invalidbodysegmentkey("'.gettype($name).'")');
}
if((null!==$parent)&&!is_string($parent)){
require_once'Zend/Controller/Response/Exception.php';
thrownewZend_Controller_Response_Exception('Invalidbodysegmentparentkey("'.gettype($parent).'")');
}
if(isset($this->_body[$name])){
unset($this->_body[$name]);
}
if((null===$parent)||!isset($this->_body[$parent])){
return$this->append($name,$content);
}
$ins=array($name=>(string)$content);
$keys=array_keys($this->_body);
$loc=array_search($parent,$keys);
if(!$before){
//Incrementlocationifnotinsertingbefore
++$loc;
}
if(0===$loc){
//Iflocationofkeyis0,we'reprepending
$this->_body=$ins+$this->_body;
}elseif($loc>=(count($this->_body))){
//Iflocationofkeyismaximal,we'reappending
$this->_body=$this->_body+$ins;
}else{
//Otherwise,insertatlocationspecified
$pre=array_slice($this->_body,0,$loc);
$post=array_slice($this->_body,$loc);
$this->_body=$pre+$ins+$post;
}
return$this;
}
/**
*Echothebodysegments
*
*@returnvoid
*/
publicfunctionoutputBody()
{
$body=implode('',$this->_body);
echo$body;
}
/**
*Registeranexceptionwiththeresponse
*
*@paramException$e
*@returnZend_Controller_Response_Abstract
*/
publicfunctionsetException(Exception$e)
{
$this->_exceptions[]=$e;
return$this;
}
/**
*Retrievetheexceptionstack
*
*@returnarray
*/
publicfunctiongetException()
{
return$this->_exceptions;
}
/**
*Hasanexceptionbeenregisteredwiththeresponse?
*
*@returnboolean
*/
publicfunctionisException()
{
return!empty($this->_exceptions);
}
/**
*Doestheresponseobjectcontainanexceptionofagiventype?
*
*@paramstring$type
*@returnboolean
*/
publicfunctionhasExceptionOfType($type)
{
foreach($this->_exceptionsas$e){
if($einstanceof$type){
returntrue;
}
}
returnfalse;
}
/**
*Doestheresponseobjectcontainanexceptionwithagivenmessage?
*
*@paramstring$message
*@returnboolean
*/
publicfunctionhasExceptionOfMessage($message)
{
foreach($this->_exceptionsas$e){
if($message==$e->getMessage()){
returntrue;
}
}
returnfalse;
}
/**
*Doestheresponseobjectcontainanexceptionwithagivencode?
*
*@paramint$code
*@returnboolean
*/
publicfunctionhasExceptionOfCode($code)
{
$code=(int)$code;
foreach($this->_exceptionsas$e){
if($code==$e->getCode()){
returntrue;
}
}
returnfalse;
}
/**
*Retrieveallexceptionsofagiventype
*
*@paramstring$type
*@returnfalse|array
*/
publicfunctiongetExceptionByType($type)
{
$exceptions=array();
foreach($this->_exceptionsas$e){
if($einstanceof$type){
$exceptions[]=$e;
}
}
if(empty($exceptions)){
$exceptions=false;
}
return$exceptions;
}
/**
*Retrieveallexceptionsofagivenmessage
*
*@paramstring$message
*@returnfalse|array
*/
publicfunctiongetExceptionByMessage($message)
{
$exceptions=array();
foreach($this->_exceptionsas$e){
if($message==$e->getMessage()){
$exceptions[]=$e;
}
}
if(empty($exceptions)){
$exceptions=false;
}
return$exceptions;
}
/**
*Retrieveallexceptionsofagivencode
*
*@parammixed$code
*@returnvoid
*/
publicfunctiongetExceptionByCode($code)
{
$code=(int)$code;
$exceptions=array();
foreach($this->_exceptionsas$e){
if($code==$e->getCode()){
$exceptions[]=$e;
}
}
if(empty($exceptions)){
$exceptions=false;
}
return$exceptions;
}
/**
*Whetherornottorenderexceptions(offbydefault)
*
*Ifcalledwithnoargumentsoranullargument,returnsthevalueofthe
*flag;otherwise,setsitandreturnsthecurrentvalue.
*
*@paramboolean$flagOptional
*@returnboolean
*/
publicfunctionrenderExceptions($flag=null)
{
if(null!==$flag){
$this->_renderExceptions=$flag?true:false;
}
return$this->_renderExceptions;
}
/**
*Sendtheresponse,includingallheaders,renderingexceptionsifso
*requested.
*
*@returnvoid
*/
publicfunctionsendResponse()
{
$this->sendHeaders();
if($this->isException()&&$this->renderExceptions()){
$exceptions='';
foreach($this->getException()as$e){
$exceptions.=$e->__toString()."\n";
}
echo$exceptions;
return;
}
$this->outputBody();
}
/**
*Magic__toStringfunctionality
*
*Proxiesto{@linksendResponse()}andreturnsresponsevalueasstring
*usingoutputbuffering.
*
*@returnstring
*/
publicfunction__toString()
{
ob_start();
$this->sendResponse();
returnob_get_clean();
}
}
Zend_Controller_Response_Http
/**Zend_Controller_Response_Abstract*/
require_once'Zend/Controller/Response/Abstract.php';
/**
*Zend_Controller_Response_Http
*
*HTTPresponseforcontrollers
*
*@usesZend_Controller_Response_Abstract
*@packageZend_Controller
*@subpackageResponse
*/
classZend_Controller_Response_HttpextendsZend_Controller_Response_Abstract
{
}
常见使用用法
如果要发送响应输出包括消息头,使用sendResponse()。
$response->sendResponse();
Note:默认地,前端控制器完成分发请求后调用sendResponse();一般地,你不需要调用它。但是,如果你想处理响应或者用它来测试你可以使用Zend_Controller_Front::returnResponse(true)设置returnResponse标志覆盖默认行为:
$front->returnResponse(true); $response=$front->dispatch(); //dosomemoreprocessing,suchaslogging... //andthensendtheoutput: $response->sendResponse();
在动作控制器中使用响应对象。把结果写进响应对象,而不是直接渲染输出和发送消息头:
//Withinanactioncontrolleraction:
//Setaheader
$this->getResponse()
->setHeader('Content-Type','text/html')
->appendBody($content);
这样做,可以在显示内容之前,将所有消息头一次发送。
Note:如果使用动作控制器的视图集成(viewintegration),你不需要在相应对象中设置渲染的视图脚本,因为Zend_Controller_Action::render()默认完成了这些。
如果程序中发生了异常,检查响应对象的isException()标志,使用getException()获取异常。此外,可以创建定制的响应对象重定向到错误页面,记录异常消息,漂亮的格式化异常消息等。
在前端控制器执行dispatch()后可以获得响应对象,或者请求前端控制器返回响应对象代替渲染输出。
//retrievepost-dispatch:
$front->dispatch();
$response=$front->getResponse();
if($response->isException()){
//log,mail,etc...
}
//Or,havethefrontcontrollerdispatch()processreturnit
$front->returnResponse(true);
$response=$front->dispatch();
//dosomeprocessing...
//finally,echotheresponse
$response->sendResponse();
默认地,异常消息是不显示的。可以通过调用renderExceptions()覆盖默认设置。或者启用前端控制器的throwExceptions():
$response->renderExceptions(true); $front->dispatch($request,$response); //or: $front->returnResponse(true); $response=$front->dispatch(); $response->renderExceptions(); $response->sendResponse(); //or: $front->throwExceptions(true); $front->dispatch();
处理消息头
如上文所述,响应对象的一项重要职责是收集和发出HTTP响应消息头,相应地存在大量的方法:
canSendHeaders()用来判别消息头是否已发送,该方法带有一个可选的标志指示消息头已发出时是否抛出异常。可以通过设置headersSentThrowsException属性为false来覆盖默认设置。
setHeader($name,$value,$replace=false)用来设置单独的消息头。默认的不会替换已经存在的同名消息头,但可以设置$replace为true强制替换.
设置消息头前,该方法先检查canSendHeaders()看操作是否允许,并请求抛出异常。
setRedirect($url,$code=302)设置HTTP定位消息头准备重定向,如果提供HTTP状态码,重定向将会使用该状态码。
其内部调用setHeader()并使$replace标志呈打开状态确保只发送一次定位消息头。
getHeaders()返回一个消息头数组,每个元素都是一个带有'name'和'value'键的数组。
clearHeaders()清除所有注册的键值消息头。
setRawHeader()设置没有键值对的原始消息头,比如HTTP状态消息头。
getRawHeaders()返回所有注册的原始消息头。
clearRawHeaders()清除所有的原始消息头。
clearAllHeaders()清除所有的消息头,包括原始消息头和键值消息头。
除了上述方法,还有获取和设置当前请求HTTP响应码的访问器,setHttpResponseCode()和getHttpResponseCode().
命名片段
相应对象支持“命名片段”。允许你将消息体分割成不同的片段,并呈一定顺序排列。因此输出的是以特定次序返回的。在其内部,主体内容被存储为一个数组,大量的访问器方法可以用来指示数组内位置和名称。
举例来说,你可以使用preDispatch()钩子来向响应对象中加入页头,然后在动作控制器中加入主体内容,最后在postDispatch()钩子中加入页脚。
//Assumethatthispluginclassisregisteredwiththefrontcontroller
classMyPluginextendsZend_Controller_Plugin_Abstract
{
publicfunctionpreDispatch(Zend_Controller_Request_Abstract$request)
{
$response=$this->getResponse();
$view=newZend_View();
$view->setBasePath('../views/scripts');
$response->prepend('header',$view->render('header.phtml'));
}
publicfunctionpostDispatch(Zend_Controller_Request_Abstract$request)
{
$response=$this->getResponse();
$view=newZend_View();
$view->setBasePath('../views/scripts');
$response->append('footer',$view->render('footer.phtml'));
}
}
//asampleactioncontroller
classMyControllerextendsZend_Controller_Action
{
publicfunctionfooAction()
{
$this->render();
}
}
上面的例子中,调用/my/foo会使得最终响应对象中的内容呈现下面的结构:
array( 'header'=>...,//headercontent 'default'=>...,//bodycontentfromMyController::fooAction() 'footer'=>...//footercontent );
渲染响应时,会按照数组中元素顺序来渲染。
大量的方法可以用来处理命名片段:
setBody()和appendBody()都允许传入一个$name参数,指示一个命名片段。如果提供了这个参数,将会覆盖指定的命名片段,如果该片段不存在就创建一个。如果没有传入$name参数到setBody(),将会重置整个主体内容。如果没有传入$name参数到appendBody(),内容被附加到'default'命名片段。
prepend($name,$content)将创建一个$name命名片段并放置在数组的开始位置。如果该片段存在,将首先移除。
append($name,$content)将创建一个$name命名片段,并放置在数组的结尾位置。如果该片段存在,将首先移除。
insert($name,$content,$parent=null,$before=false)将创建一个$name命名片段。如果提供$parent参数,新的片段视$before的值决定放置在
$parent的前面或者后面。如果该片段存在,将首先移除。
clearBody($name=null)如果$name参数提供,将删除该片段,否则删除全部。
getBody($spec=false)如果$spec参数为一个片段名称,将可以获取到该字段。若$spec参数为false,将返回字符串格式的命名片段顺序链。如果$spec参数为true,返回主体内容数组。
在响应对象中测试异常
如上文所述,默认的,分发过程中的异常发生会在响应对象中注册。异常会注册在一个堆中,允许你抛出所有异常--程序异常,分发异常,插件异常等。如果你要检查或者记录特定的异常,你可能想要使用响应对象的异常API:
setException(Exception$e)注册一个异常。
isException()判断该异常是否注册。
getException()返回整个异常堆。
hasExceptionOfType($type)判断特定类的异常是否在堆中。
hasExceptionOfMessage($message)判断带有指定消息的异常是否在堆中。
hasExceptionOfCode($code)判断带有指定代码的异常是否在堆中。
getExceptionByType($type)获取堆中特定类的所有异常。如果没有则返回false,否则返回数组。
getExceptionByMessage($message)获取堆中带有特定消息的所有异常。如果没有则返回false,否则返回数组。
getExceptionByCode($code)获取堆中带有特定编码的所有异常。如果没有则返回false,否则返回数组。
renderExceptions($flag)设置标志指示当发送响应时是否发送其中的异常。
自定义响应对象
响应对象的目的首先在于从大量的动作和插件中收集消息头和内容,然后返回到客户端;其次,响应对象也收集发生的任何异常,以处理或者返回这些异常,再或者对终端用户隐藏它们。
响应的基类是Zend_Controller_Response_Abstract,创建的任何子类必须继承这个类或它的衍生类。前面的章节中已经列出了大量可用的方法。
自定义响应对象的原因包括基于请求环境修改返回的内容的输出方式(例如:在CLI和PHP-GTK请求中不发送消息头)增加返回存储在命名片段中内容的最终视图的功能等等。
更多关于zend相关内容感兴趣的读者可查看本站专题:《ZendFrameWork框架入门教程》、《php优秀开发框架总结》、《Yii框架入门及常用技巧总结》、《ThinkPHP入门教程》、《php面向对象程序设计入门教程》、《php+mysql数据库操作入门教程》及《php常见数据库操作技巧汇总》
希望本文所述对大家PHP程序设计有所帮助。