| 订阅 | 在线投稿
分享
 
 
当前位置: 王朝网络 >> php >> yong PEAR lai xie ni de PHP cheng xu

yong PEAR lai xie ni de PHP cheng xu

2008-12-22 08:07:53 编辑來源:互联网 评论
 
 
 
本文为【用PEAR来写你的PHP程序】的拼音翻译版
  ru qian suo shu ,PEAR an zhao yi ding de fen lei lai guan li PEAR ying yong dai ma ku , ni de PEAR dai ma ke yi zu zhi dao qi zhong shi dang de mu lu zhong , qi ta de ren ke yi fang bian di jian suo bing fen xiang dao ni de cheng guo 。 PEAR bu jin jin shi yi ge dai ma cang ku , ta tong shi ye shi yi ge biao zhun , shi yong zhe ge biao zhun lai shu xie ni de PHP dai ma , jiang hui zeng qiang ni de cheng xu de ke du xing , fu yong xing , jian shao chu cuo de ji lv 。 PEAR tong guo ti gong 2 ge lei wei ni da jian le yi ge kuang jia , shi xian le zhu ru xi gou han shu , cuo wu bu huo gong neng , ni tong guo ji cheng jiu ke yi shi yong zhe xie gong neng 。
  PEAR de bian ma gui ze bao kuo suo jin gui ze , kong zhi jie gou , han shu tiao yong , han shu ding yi , zhu shi , bao han dai ma ,PHP biao ji , wen jian tou de zhu shi kuai ,CVS biao ji ,URL yang li , chang liang de ming ming zhe 11 fang mian 。 xia mian jian yao di jie shao yi xia :
  suo jin gui ze :
  PEAR zhong xu yao shi yong 4 ge kong ge lai suo pai dai ma , bing qie bu shi yong TAB。 ru guo ni shi yong VIM, jiang xia lie she zhi fang ru ni de ~/.vimrc zhong :set expandtab
  set shiftwidth=4
  set tabstop=4
  ru guo , ni shi yong Emacs/XEmacs, xu yao ba indent-tabs-mode she zhi cheng nil。
  bu guo ni xiang wo yi yang xi huan yong (X)Emacs bian ji PHP wen jian , wo qiang lie tui jian ni an zhuang PHP-MODE, zhe yang dang ni bian xie PEAR dai ma de shi hou , ta hui zi dong tiao zheng ni de suo pai feng ge , dang ran PHP-MODE huan you xu duo hen you xiu de te xing , ni ke yi cong zi yuan lie biao zhong de di fang xia zai zui xin ban de PHP-MODE。
  kong zhi jie gou :
  zhe li suo shuo de kong zhi jie gou bao kuo : if for while switch deng 。 dui yu kong zhi jie gou , zai guan jian zi ( ru if for ..) hou mian yao kong yi ge ge , ran hou zai gen kong zhi de yuan kuo hao , zhe yang , bu zhi yu he han shu tiao yong hun xiao , ci wai , ni ying gai jin liang wan zheng de shi yong hua kuo hao {}, ji shi cong yu fa shang lai shuo shi ke xuan de 。 zhe yang ke yi fang zhi ni yi hou xu tian jia xin de dai ma xing shi chan sheng luo ji shang de yi huo huo zhe cuo wu 。 zhe li shi yi ge yang li :if (( tiao jian 1) && ( tiao jian 2)) {
   yu ju 1;
  }esleif (( tiao jian 3) || ( tiao jian 4)) {
   yu ju 2;
  }else {
   yu ju 3;
  }
  han shu tiao yong :
  dui yu han shu tiao yong , han shu ming he zuo kuo hao ( zhi jian bu ying gai you kong ge , dui yu han shu shen shu , zai fen ge de dou hao he xia yi ge shen shu zhi jian yao you xiang tong de kong ge fen li , zui hou yi ge shen shu he you kuo hao zhi jian bu neng you kong ge 。 xia mian shi yi ge biao zhun de han shu tiao yong ;$result = foo($param1, $param2, $param3);
  bu gui fan de xie fa :
  $result=foo ($param1,$param2,$param3);
  $result=foo( $param1,$param2, $param3 );
  ci wai , ru guo yao jiang han shu de fan hui jie guo fu zhi , na me zai deng hao he suo fu zhi de bian liang zhi jian yao you kong ge , tong shi , ru guo shi yi xi lie xiang guan de fu zhi yu ju , ni tian jia shi dang de kong ge , shi ta men dui qi , jiu xiang zhe yang :$result1 = $foo($param1, $param2, $param3);
  $var2 = $foo($param3);
  $var3 = $foo($param4, $param5);
  han shu ding yi :
  han shu ding yi zun xun "one true brace" xi su :function connect(&$dsn, $persistent = false){
   if (is_array($dsn)) {
   $dsninfo = &&dsn;
   } else {
   $dsninfo = DB::parseDSN($dsn);
   }
   if (!$dsninfo || !$dsninfo['phptype']) {
   return $this->raiseError();
   }
   return true;
  }
  ru shang suo shi , ke xuan shen shu yao zai shen shu biao de mo duan , bing qie zong shi jin liang fan hui you yi yi de han shu zhi 。
  guan yu zhu shi :
  dui yu lei de zai xian wen dang , ying gai neng gou bei PHPDoc zhuan huan , jiu xiang JavaDoc na yang 。PHPDoc ye shi yi ge PEAR de ying yong cheng xu , geng xiang xi de jie shao ni ke yi qu http://www.phpdoc.de/ cha kan 。 chu le lei de zai xian wen dang , jian yi ni ying gai shi yong fei wen dang xing zhi de zhu shi lai quan shi ni de dai ma , dang ni kan dao yi duan dai ma shi xiang : o , wo xiang bu xu yao zai wen dang li qu zai xi miao shu ta ba 。 na me ni zui hao gei zhe duan dai ma zuo yi ge jian dan de zhu shi , zhe yang fang zhi ni hui wang ji ta men shi ru he gong zuo de 。 dui yu zhu shi de xing shi ,C de /* */ he C++ de // dou bu cuo , bu guo , bu yao shi yong Perl huo zhe shell de # zhu shi fang shi 。
  bao han dai ma :
  wu lun shen me shi hou , dang ni xu yao wu tiao jian bao han jin yi ge class wen jian , ni bi xu shi yong requre_once; dang ni xu yao tiao jian bao han jin yi ge class wen jian , ni bi xu shi yong include_once; zhe yang ke yi bao zheng ni yao bao han de wen jian zhi hui bao han yi ci , bing qie zhe 2 ge yu ju gong yong tong yi ge wen jian lie biao , suo yi ni wu xu dan xin er zhe hui hun xiao , yi dan require_once bao han le yi ge wen jian ,include_once bu hui zai chong fu bao han xiang tong de wen jian , fan zhi yi ran 。
  PHP dai ma biao ji :
  ren he shi hou dou yao shi yong ding yi ni de php dai ma , er bu yao jian dan di shi yong , zhe yang ke yi bao zheng PEAR de jian rong xing , ye li yu kua ping tai de yi zhi 。
  wen jian tou de zhu shi sheng ming :
  suo you xu yao bao han zai PEAR gai xin fa bu de PHP dai ma wen jian , zai wen jian kai shi de shi hou , ni bi xu jia ru yi xia de zhu shi sheng ming :/* vim: set expandtab tabstop=4 shiftwidth=4: */
  // +----------------------------------------------------------------------+
  // | PHP version 4.0 |
  // +----------------------------------------------------------------------+
  // | Copyright (c) 1997, 1998, 1999, 2000, 2001 The PHP Group |
  // +----------------------------------------------------------------------+
  // | This source file is subject to version 2.0 of the PHP license, |
  // | that is bundled with this package in the file LICENSE, and is |
  // | available at through the world-wide-web at |
  // | http://www.php.net/license/2_02.txt. |
  // | If you did not receive a copy of the PHP license and are unable to |
  // | obtain it through the world-wide-web, please send a note to |
  // | license@php.net so we can mail you a copy immediately. |
  // +----------------------------------------------------------------------+
  // | Authors: Original Author |
  // | Your Name |
  // +----------------------------------------------------------------------+
  //
  // $Id$
  dui yu bu zai PEAR gai xin dai ma ku zhong de wen jian , jian yi ni ye zai wen jian de kai shi chu you zhe yang yi ge lei si de zhu shi kuai , biao ming ban quan , xie yi , zuo zhe deng deng 。 tong shi ye zai di yi xing jia ru VIM de MODELINE, zhe yang zai VIM zhong neng gou bao chi PEAR de dai ma feng ge 。
  CVS biao ji :
  ru shang mian suo zhan shi na yang , zai mei ge wen jian zhong jia ru CVS de ID biao ji , ru guo ni bian ji huo xiu gai de wen jian zhong mei you zhe ge biao ji , na me qing jia ru , huo zhe shi ti huan yuan wen jian zhong xiang lei si de biao xian xing shi ( ru "Last modified" deng deng )
  URL yang ben :
  ni ke yi shen zhao RFC 2606, shi yong "www.example.com" zuo wei suo you de URL yang ben 。
  chang liang ming ming :
  chang liang ying gai jin liang shi yong da xie , wei le bian yu li jie , shi yong xia hua xian fen ge mei ge dan ci 。 tong shi , ni ying gai chang liang suo zai de bao ming huo zhe shi lei ming zuo wei qian zhui 。 bi ru , dui yu Bug lei zhong chang liang ying gai yi Bug_ kai shi 。 yi shang shi PEAR de bian ma gui ze , xiang xi de bian ma gui ze ke yi shen kao PEAR zhong de CODING_STANDDARD wen jian de shuo ming 。 wei le geng hao di li jie zhe xie bian ma gui ze , ni ye ke yi shen kao yi xia xian you PEAR gai xin mo kuai de dai ma 。
  kai shi shi yong PEAR
  shi yong PEAR hen jian dan , ni zhi xu zhe yang ding yi ni zi ji de PEAR cheng xu :require_once "PEAR.php";
  class your_class_name extends PEAR{
  ni de lei ding yi ...
  }
  dang ran , ni xu yao zun shou qian mian shuo de PEAR de bian ma gui ze , zhi hou ni jiu ke yi zai ni de lei nei bu shi xian ni yao zuo de shi qing le 。 xia mian , wo men zhan kai tao lun yi xia , shi ji shang PEAR wei wo men ti gong le 2 ge yu ding yi lei : PEAR: zhe shi PEAR de ji lei , suo you de PEAR kuo zhan dou yao cong ta ji cheng pai sheng chu lai 。 PEAR_Error:PEAR de cuo wu chu li de ji lei , ni ke yi xuan ze pai sheng chu zi ji de cuo wu chu li de lei 。
  yi ban lai shuo , ni bu ying gai zhi jie chuang jian PEAR de shi li , er shi yao zi ji pai sheng chu yi ge xin de lei , ran hou zai chuang jian zhe ge xin lei de shi li 。 zuo wei ji lei ,PEAR gei wo men ti gong le yi xie you yong de gong neng , zui zhu yao de jiu shi xi gou han shu he cuo wu chu li
  xi gou han shu
  PHP zhi chi gou zao han shu , dan shi bing bu zhi chi xi gou han shu , bu guo ,PHP ti gong register_shutdown_function() zhe ge han shu , cong er neng gou zai jiao ben zhong zhi qian hui tiao zhu ce de han shu , yin ci PEAR li yong zhe ge te xing , ti gong le xi gou han shu de fang zhen 。 jia ru ni you yi ge PEAR de zi lei , jiao zuo mypear, na me zai mypear lei zhong , ni ke yi ding yi yi ge han shu , han shu ming shi xia hua xian jia shang ni de lei ming ,_mypear(), zhe ge han shu jiu shi zhe ge lei de xi gou han shu 。 bu guo zhe ge xi gou han shu he C++ zhong de xi gou han shu bu tai yi yang , ta bu hui zai dui xiang bei shan chu de shi hou zhi xing , er shi zai jiao ben jie shu de shi hou , bi jing zhe zhi shi yi ge fang zhen 。 you yu shi shi yong le register_shutdown_function(), suo yi zai ni de xi gou han shu li , da yin de xin xi jiang bu hui fan hui liu lan qi zhong 。 ci wai , zai ni de gou zao han shu zhong , xu yao tiao yong yi xia ta de fu lei de gou zao han shu , yin wei PHP bu hui zi dong tiao yong fu lei de gou zao han shu , er xi gou han shu xu yao zai PEAR de gou zao han shu zhong zhu ce , wo men ke yi kan kan PEAR de yuan dai ma :function PEAR() {
  if (method_exists($this, "_".get_class($this))) {
   global $_PEAR_destructor_object_list;
   $_PEAR_destructor_object_list[] = &this;
  }
  if ($this->_debug) {
   printf("PEAR constructor called, class=%s\n",
   get_class($this));
  }
  .....
  function _PEAR_call_destructors() {
   global $_PEAR_destructor_object_list;
   if (is_array($_PEAR_destructor_object_list) && sizeof($_PEAR_destructor_object_list)) {
   reset($_PEAR_destructor_object_list);
   while (list($k, $objref) = each($_PEAR_destructor_object_list)) {
   $destructor = "_".get_class($objref);
   if (method_exists($objref, $destructor)) {
   $objref->$destructor();
   }
   }
   // qing kong yi zhu ce de dui xiang lie biao ,
   // fang zhi chong fu tiao yong
   $_PEAR_destructor_object_list = array();
   }}
  ....
  register_shutdown_function("_PEAR_call_destructors");
  shang mian zhe duan dai ma zhan shi le PEAR shi ru he shi xian xi gou han shu de , zai gou jian han shu zhong , jiang jian cha dang qian lei zhong shi fou you xi gou han shu , ru guo you , na me jiang ba dang qian lei de yin yong fang ru yi ge quan ju lie biao zhong , zai _PEAR_call_destructors zhong , ze jian cha zhe ge quan ju lie biao zhong de mei ge yuan su shi fou cun zai xiang ying de xi gou han shu , ru guo you , ze tiao yong ta , zui hou jiang quan ju lie biao qing kong 。
  zai PEAR.php de zui hou yi xing dai ma , ze tiao yong register_shutdown_function("_PEAR_call_destructors"), zhu ce _PEAR_call_destructors, zhe yang , dang jiao ben zhi xing wan bi de shi hou ,PHP hui hui tiao zhe ge han shu 。 shi yong xi gou han shu , ni ke yi zai chu li wan yong hu de qing qiu , tui chu zhi qian zuo yi xie bi yao de " shan hou " gong zuo , dian xing de li zi shi , ni ke yi guan bi da kai de wen jian , duan kai shu ju ku de lian jie , jiang mou xie shu ju cun ru ci pan deng deng 。
  cuo wu chu li
  PEAR zhong ke yi rang ni you hen duo de fang shi lai chu li cuo wu , ni bu jin jin shi jian dan di fan hui yi ge cuo wu dai ma , huo zhe cuo wu de xin xi , er shi ke yi fan hui yi ge PEAR_Error dui xiang , huo zhe shi you PEAR_Error pai sheng chu lai de xin de cuo wu dui xiang 。
  PEAR zhong de cuo wu dui xiang de bing mei you xian ding ju ti de shu chu xing shi , ta ke yi jin jin shi bu huo cuo wu , bu gei yong hu fan hui tai duo de xin xi , ye ke yi shi qu hui tiao yi ge te shu cuo wu chu li han shu , tong shi , ji shi shu chu cuo wu xin xi , ta ye qiang po ni bi xu yao shi HTML xing shi , ni ke yi shu chu XML,CSV xing shi , huo zhe shi qi ta ni zi ji ding yi de xing shi , ni zhi xu yao cong PEAR_Error pai sheng yi ge xin de lei , ran hou zai shi dang de shi hou chuang jian bing " pao chu " zhe ge xin lei de dui xiang jiu ke yi le 。
  jian dan de cuo wu chu li :
  zai PEAR zhong , zui jian dan de cuo wu chu li shi " pao chu " zhe ge cuo wu , ni zhi yao jian dan di chuang jian bing fan hui yi ge PEAR_Error de dui xiang jiu ke yi le 。 xia mian shi yi ge jian dan de li zi :function myconnect($host = "localhost", $port = 1080){
   $fp = fsockopen($host, $port, $errno, $errstr);
   if (!is_resource($fp)) {
   return new PEAR_Error($errstr, $errno);
   }
   return $fp;
  }
  $sock = myconnect();
  if (PEAR::isError($sock)) {
   print "connect error: ".$sock->getMessage()."\n"
  }
  ru shang mian dai ma suo zhan shi de , zai zhi xing yi duan ke neng chan sheng cuo wu de dai ma hou , ni xu yao shi yong PEAR de isError lai jian ce shi fou cun zai cuo wu , bing qie ke yi shi yong PEAR_Error de getMessage lai qu de zui jin yi ci de cuo wu xin xi 。 zhu yi : yi ding yao zai guan jian de di fang shi yong shi yong PEAR::isError
  shi yong raiseError
  PHP4.0.5 yi hou ,PEAR duo le 2 ge han shu :
  setErrorHandling($mode, $options = null)
  raiseError($message = null, $code = null, $mode = null,$options = null, $userinfo = null)
  qian zhe ke yi she zhi PEAR que sheng de cuo wu chu li mo shi , hou zhe shi yi ge bao zhuang han shu , fan hui yi ge PEAR_Error de dui xiang , he zhi jie chuang jian bing fan hui PEAR_Error de dui xiang lue you bu tong de shi , ru guo sheng lue $mode,$options deng shen shu , ta hui shi yong que sheng zhi lai chuang jian zhe ge PEAR_Error de dui xiang , zhe xie que sheng zhi ni ke yi shi yong setErrorHandling() lai ding zhi 。
  PEAR_Error
  PEAR_Error shi PEAR de cuo wu dui xiang de yi ge ji lei , he PEAR bu tong , yi ban lai shuo , ni ke yi zhi jie chuang jian PEAR_Error de shi li , chuang jian fang shi : $error = new PEAR_Error($message, $code, $mode, $options, $userinfo);
  $message shi ni de cuo wu xin xi ,$code shi gai cuo wu de cuo wu hao , hou 3 ge shen shu shi jin mi lian xi de :
  $mode: shi zhe ge cuo wu de chu li mo shi , ke yi xia lie chang liang :
  PEAR_ERROR_RETURN: jin jin fan hui gai cuo wu dui xiang ( que sheng fang shi )
  PEAR_ERROR_PRINT: zai gou jian han shu zhong da yin zhe ge cuo wu xin xi , dan shi dang qian cheng xu hui ji xu yun xing 。
  PEAR_ERROR_TRIGGER: shi yong PHP de trigger_error() chu fa yi ge cuo wu , ru guo ni yi jing she zhi le cuo wu chu li han shu , huo zhe ni ba PHP de cuo wu chu li ji bie she zhi wei E_USER_ERROR, na me dang qian cheng xu jiang hui bei zhong zhi 。
  PEAR_ERROR_DIE: da yin cuo wu bing tui chu , cheng xu zhong zhi 。
  PEAR_ERROR_CALLBACK: shi yong yi ge hui tiao han shu huo zhe fang fa lai chu li dang qian cuo wu , cheng xu zhong zhi 。
  $options: zhe ge shen shu zhi you zai $mode shi PEAR_ERROR_TRIGGER he PEAR_ERROR_CALLBACK de shi hou cai qi zuo yong , ru guo shi PEAR_ERROR_TRIGGER,$options bi xu shi E_USER_NOTICE, E_USER_WARNING huo E_USER_ERROR zhe 3 ge chang liang de yi ge , tong PHP zhong trigger_error de zhi yi zhi 。 ru guo $mode shi PEAR_ERROR_CALLBACK, $options ke yi shi yi ge zi fu chuan , nei rong shi yao hui tiao de han shu ming , ye ke yi shi yi ge 2 yuan su de shu zu , fen bie shi yi ge dui xiang bian liang , he yi ge zi fu chuan ( biao ming yao tiao yong de fang fa )。
  $userinfo: cun fang fu jia de yong hu xin xi , ni ke yi ba xiang guan de tiao shi xin xi fang zai zhe li 。
  PEAR_Error zhong you yi xie chang yong de fang fa , zhe xie fang fa zai PHP wen dang mei you miao shu , zhe li yi yi lie chu :
  int getMode: fan hui dang qian de cuo wu chu li mo shi , zheng xing 。
  string getMessage: fan hui dang qian wan zheng de cuo wu xin xi , zi fu chuan 。
  mixed getCallback: fan hui dang qian de hui tiao xin xi , ke neng shi suo hui tiao de han shu ming , huo zhe shi ( dui xiang , fang fa ) de shu zu 。
  int getCode: fan hui zheng xing de cuo wu dai ma 。
  string getType: fan hui cuo wu de lei xing , ye jiu shi dang qian de lei ming , zi fu chuan 。
  string getUserInfo: fan hui fu jia de yong hu xin xi , zi fu chuan 。
  string getDebugInfo: nei rong tong shang 。
  string toString: fan hui dang qian dui xiang de xiang xi zi fu chuan miao shu , nei rong bao kuo cuo wu chu li de mo shi , ji bie , cuo wu xin xi , cuo wu dai ma , xiang guan hui tiao han shu deng deng 。
  zong jie
  zhi ci , dui yu PEAR de jie shao jiu jie shu le 。 gai kuo di shuo , ru guo ni yao zuo yi ge PEAR de kuo zhan ying yong , xu yao zhe me zuo :
  require_once "PEAR.php"
  shi yong class your_pear_extend extends PEAR{} ding yi ni de xin lei 。
  zai ni de lei de gou zao han shu zhong , tiao yong fu lei PEAR de gou zao han shu :function your_pear_extend{
   $this->PEAR();
   ...
  }
  ru guo xu yao , ding yi ni de xi gou han shu _your_pear_extend
  ru guo xu yao , cong PEAR_Error pai sheng chu ni zi ji de cuo wu chu li lei
  she zhi ni de cuo wu chu li mo shi , bing zai shi dang de shi hou chu fa cuo wu 。
  zai zhi xing ke neng chan sheng cuo wu de dai ma hou , yong PEAR::isError($obj) bu huo xiang ying de cuo wu 。
  shi xian ni zi ji de gong neng 。
  zai PEAR gai xin fa bu li , yi jing you bu shao you xiu de ying yong mo kuai le , bi ru :PHPDoc,Cache,HTML。【原文】【汉音对照
 
 
 
 
 
 
 
 
 
日版宠物情人插曲《Winding Road》歌词

日版宠物情人2017的插曲,很带节奏感,日语的,女生唱的。 最后听见是在第8集的时候女主手割伤了,然后男主用嘴帮她吸了一下,插曲就出来了。 歌手:Def...

兄弟共妻,我成了他们夜里的美食

老钟家的两个儿子很特别,就是跟其他的人不太一样,魔一般的执着。兄弟俩都到了要结婚的年龄了,不管自家老爹怎么磨破嘴皮子,兄弟俩说不娶就不娶,老父母为兄弟两操碎了心...

如何磨出破洞牛仔裤?牛仔裤怎么剪破洞?

把牛仔裤磨出有线的破洞 1、具体工具就是磨脚石,下面垫一个硬物,然后用磨脚石一直磨一直磨,到把那块磨薄了,用手撕开就好了。出来的洞啊很自然的。需要猫须的话调几...

我就是扫描下图得到了敬业福和爱国福

先来看下敬业福和爱国福 今年春节,支付宝再次推出了“五福红包”活动,表示要“把欠大家的敬业福都还给大家”。 今天该活动正式启动,和去年一样,需要收集“五福”...

冰箱异味产生的原因和臭味去除的方法

有时候我们打开冰箱就会闻到一股异味,冰箱里的这种异味是因为一些物质发出的气味的混合体,闻起来让人恶心。 产生这些异味的主要原因有以下几点。 1、很多人有这种习...

 
 
ru qian suo shu ,PEAR an zhao yi ding de fen lei lai guan li PEAR ying yong dai ma ku , ni de PEAR dai ma ke yi zu zhi dao qi zhong shi dang de mu lu zhong , qi ta de ren ke yi fang bian di jian suo bing fen xiang dao ni de cheng guo 。 PEAR bu jin jin shi yi ge dai ma cang ku , ta tong shi ye shi yi ge biao zhun , shi yong zhe ge biao zhun lai shu xie ni de PHP dai ma , jiang hui zeng qiang ni de cheng xu de ke du xing , fu yong xing , jian shao chu cuo de ji lv 。 PEAR tong guo ti gong 2 ge lei wei ni da jian le yi ge kuang jia , shi xian le zhu ru xi gou han shu , cuo wu bu huo gong neng , ni tong guo ji cheng jiu ke yi shi yong zhe xie gong neng 。 PEAR de bian ma gui ze bao kuo suo jin gui ze , kong zhi jie gou , han shu tiao yong , han shu ding yi , zhu shi , bao han dai ma ,PHP biao ji , wen jian tou de zhu shi kuai ,CVS biao ji ,URL yang li , chang liang de ming ming zhe 11 fang mian 。 xia mian jian yao di jie shao yi xia : suo jin gui ze : PEAR zhong xu yao shi yong 4 ge kong ge lai suo pai dai ma , bing qie bu shi yong TAB。 ru guo ni shi yong VIM, jiang xia lie she zhi fang ru ni de ~/.vimrc zhong :set expandtab set shiftwidth=4 set tabstop=4 ru guo , ni shi yong Emacs/XEmacs, xu yao ba indent-tabs-mode she zhi cheng nil。 bu guo ni xiang wo yi yang xi huan yong (X)Emacs bian ji PHP wen jian , wo qiang lie tui jian ni an zhuang PHP-MODE, zhe yang dang ni bian xie PEAR dai ma de shi hou , ta hui zi dong tiao zheng ni de suo pai feng ge , dang ran PHP-MODE huan you xu duo hen you xiu de te xing , ni ke yi cong zi yuan lie biao zhong de di fang xia zai zui xin ban de PHP-MODE。 kong zhi jie gou : zhe li suo shuo de kong zhi jie gou bao kuo : if for while switch deng 。 dui yu kong zhi jie gou , zai guan jian zi ( ru if for ..) hou mian yao kong yi ge ge , ran hou zai gen kong zhi de yuan kuo hao , zhe yang , bu zhi yu he han shu tiao yong hun xiao , ci wai , ni ying gai jin liang wan zheng de shi yong hua kuo hao {}, ji shi cong yu fa shang lai shuo shi ke xuan de 。 zhe yang ke yi fang zhi ni yi hou xu tian jia xin de dai ma xing shi chan sheng luo ji shang de yi huo huo zhe cuo wu 。 zhe li shi yi ge yang li :if (( tiao jian 1) && ( tiao jian 2)) { yu ju 1; }esleif (( tiao jian 3) || ( tiao jian 4)) { yu ju 2; }else { yu ju 3; } han shu tiao yong : dui yu han shu tiao yong , han shu ming he zuo kuo hao ( zhi jian bu ying gai you kong ge , dui yu han shu shen shu , zai fen ge de dou hao he xia yi ge shen shu zhi jian yao you xiang tong de kong ge fen li , zui hou yi ge shen shu he you kuo hao zhi jian bu neng you kong ge 。 xia mian shi yi ge biao zhun de han shu tiao yong ;$result = foo($param1, $param2, $param3); bu gui fan de xie fa : $result=foo ($param1,$param2,$param3); $result=foo( $param1,$param2, $param3 ); ci wai , ru guo yao jiang han shu de fan hui jie guo fu zhi , na me zai deng hao he suo fu zhi de bian liang zhi jian yao you kong ge , tong shi , ru guo shi yi xi lie xiang guan de fu zhi yu ju , ni tian jia shi dang de kong ge , shi ta men dui qi , jiu xiang zhe yang :$result1 = $foo($param1, $param2, $param3); $var2 = $foo($param3); $var3 = $foo($param4, $param5); han shu ding yi : han shu ding yi zun xun "one true brace" xi su :function connect(&$dsn, $persistent = false){ if (is_array($dsn)) { $dsninfo = &&dsn; } else { $dsninfo = DB::parseDSN($dsn); } if (!$dsninfo || !$dsninfo['phptype']) { return $this->raiseError(); } return true; } ru shang suo shi , ke xuan shen shu yao zai shen shu biao de mo duan , bing qie zong shi jin liang fan hui you yi yi de han shu zhi 。 guan yu zhu shi : dui yu lei de zai xian wen dang , ying gai neng gou bei PHPDoc zhuan huan , jiu xiang JavaDoc na yang 。PHPDoc ye shi yi ge PEAR de ying yong cheng xu , geng xiang xi de jie shao ni ke yi qu [url=http://www.phpdoc.de/]http://www.phpdoc.de/[/url] cha kan 。 chu le lei de zai xian wen dang , jian yi ni ying gai shi yong fei wen dang xing zhi de zhu shi lai quan shi ni de dai ma , dang ni kan dao yi duan dai ma shi xiang : o , wo xiang bu xu yao zai wen dang li qu zai xi miao shu ta ba 。 na me ni zui hao gei zhe duan dai ma zuo yi ge jian dan de zhu shi , zhe yang fang zhi ni hui wang ji ta men shi ru he gong zuo de 。 dui yu zhu shi de xing shi ,C de /* */ he C++ de // dou bu cuo , bu guo , bu yao shi yong Perl huo zhe shell de # zhu shi fang shi 。 bao han dai ma : wu lun shen me shi hou , dang ni xu yao wu tiao jian bao han jin yi ge class wen jian , ni bi xu shi yong requre_once; dang ni xu yao tiao jian bao han jin yi ge class wen jian , ni bi xu shi yong include_once; zhe yang ke yi bao zheng ni yao bao han de wen jian zhi hui bao han yi ci , bing qie zhe 2 ge yu ju gong yong tong yi ge wen jian lie biao , suo yi ni wu xu dan xin er zhe hui hun xiao , yi dan require_once bao han le yi ge wen jian ,include_once bu hui zai chong fu bao han xiang tong de wen jian , fan zhi yi ran 。 PHP dai ma biao ji : ren he shi hou dou yao shi yong ding yi ni de php dai ma , er bu yao jian dan di shi yong , zhe yang ke yi bao zheng PEAR de jian rong xing , ye li yu kua ping tai de yi zhi 。 wen jian tou de zhu shi sheng ming : suo you xu yao bao han zai PEAR gai xin fa bu de PHP dai ma wen jian , zai wen jian kai shi de shi hou , ni bi xu jia ru yi xia de zhu shi sheng ming :/* vim: set expandtab tabstop=4 shiftwidth=4: */ // +----------------------------------------------------------------------+ // | PHP version 4.0 | // +----------------------------------------------------------------------+ // | Copyright (c) 1997, 1998, 1999, 2000, 2001 The PHP Group | // +----------------------------------------------------------------------+ // | This source file is subject to version 2.0 of the PHP license, | // | that is bundled with this package in the file LICENSE, and is | // | available at through the world-wide-web at | // | [url=http://www.php.net/license/2_02.txt]http://www.php.net/license/2_02.txt[/url]. | // | If you did not receive a copy of the PHP license and are unable to | // | obtain it through the world-wide-web, please send a note to | // | [url=mailto:license@php.net]license@php.net[/url] so we can mail you a copy immediately. | // +----------------------------------------------------------------------+ // | Authors: Original Author | // | Your Name | // +----------------------------------------------------------------------+ // // $Id$ dui yu bu zai PEAR gai xin dai ma ku zhong de wen jian , jian yi ni ye zai wen jian de kai shi chu you zhe yang yi ge lei si de zhu shi kuai , biao ming ban quan , xie yi , zuo zhe deng deng 。 tong shi ye zai di yi xing jia ru VIM de MODELINE, zhe yang zai VIM zhong neng gou bao chi PEAR de dai ma feng ge 。 CVS biao ji : ru shang mian suo zhan shi na yang , zai mei ge wen jian zhong jia ru CVS de ID biao ji , ru guo ni bian ji huo xiu gai de wen jian zhong mei you zhe ge biao ji , na me qing jia ru , huo zhe shi ti huan yuan wen jian zhong xiang lei si de biao xian xing shi ( ru "Last modified" deng deng ) URL yang ben : ni ke yi shen zhao RFC 2606, shi yong "[url=http://www.example.com]www.example.com[/url]" zuo wei suo you de URL yang ben 。 chang liang ming ming : chang liang ying gai jin liang shi yong da xie , wei le bian yu li jie , shi yong xia hua xian fen ge mei ge dan ci 。 tong shi , ni ying gai chang liang suo zai de bao ming huo zhe shi lei ming zuo wei qian zhui 。 bi ru , dui yu Bug lei zhong chang liang ying gai yi Bug_ kai shi 。 yi shang shi PEAR de bian ma gui ze , xiang xi de bian ma gui ze ke yi shen kao PEAR zhong de CODING_STANDDARD wen jian de shuo ming 。 wei le geng hao di li jie zhe xie bian ma gui ze , ni ye ke yi shen kao yi xia xian you PEAR gai xin mo kuai de dai ma 。 kai shi shi yong PEAR shi yong PEAR hen jian dan , ni zhi xu zhe yang ding yi ni zi ji de PEAR cheng xu :require_once "PEAR.php"; class your_class_name extends PEAR{ ni de lei ding yi ... } dang ran , ni xu yao zun shou qian mian shuo de PEAR de bian ma gui ze , zhi hou ni jiu ke yi zai ni de lei nei bu shi xian ni yao zuo de shi qing le 。 xia mian , wo men zhan kai tao lun yi xia , shi ji shang PEAR wei wo men ti gong le 2 ge yu ding yi lei : PEAR: zhe shi PEAR de ji lei , suo you de PEAR kuo zhan dou yao cong ta ji cheng pai sheng chu lai 。 PEAR_Error:PEAR de cuo wu chu li de ji lei , ni ke yi xuan ze pai sheng chu zi ji de cuo wu chu li de lei 。 yi ban lai shuo , ni bu ying gai zhi jie chuang jian PEAR de shi li , er shi yao zi ji pai sheng chu yi ge xin de lei , ran hou zai chuang jian zhe ge xin lei de shi li 。 zuo wei ji lei ,PEAR gei wo men ti gong le yi xie you yong de gong neng , zui zhu yao de jiu shi xi gou han shu he cuo wu chu li xi gou han shu PHP zhi chi gou zao han shu , dan shi bing bu zhi chi xi gou han shu , bu guo ,PHP ti gong register_shutdown_function() zhe ge han shu , cong er neng gou zai jiao ben zhong zhi qian hui tiao zhu ce de han shu , yin ci PEAR li yong zhe ge te xing , ti gong le xi gou han shu de fang zhen 。 jia ru ni you yi ge PEAR de zi lei , jiao zuo mypear, na me zai mypear lei zhong , ni ke yi ding yi yi ge han shu , han shu ming shi xia hua xian jia shang ni de lei ming ,_mypear(), zhe ge han shu jiu shi zhe ge lei de xi gou han shu 。 bu guo zhe ge xi gou han shu he C++ zhong de xi gou han shu bu tai yi yang , ta bu hui zai dui xiang bei shan chu de shi hou zhi xing , er shi zai jiao ben jie shu de shi hou , bi jing zhe zhi shi yi ge fang zhen 。 you yu shi shi yong le register_shutdown_function(), suo yi zai ni de xi gou han shu li , da yin de xin xi jiang bu hui fan hui liu lan qi zhong 。 ci wai , zai ni de gou zao han shu zhong , xu yao tiao yong yi xia ta de fu lei de gou zao han shu , yin wei PHP bu hui zi dong tiao yong fu lei de gou zao han shu , er xi gou han shu xu yao zai PEAR de gou zao han shu zhong zhu ce , wo men ke yi kan kan PEAR de yuan dai ma :function PEAR() { if (method_exists($this, "_".get_class($this))) { global $_PEAR_destructor_object_list; $_PEAR_destructor_object_list[] = &this; } if ($this->_debug) { printf("PEAR constructor called, class=%s\n", get_class($this)); } ..... function _PEAR_call_destructors() { global $_PEAR_destructor_object_list; if (is_array($_PEAR_destructor_object_list) && sizeof($_PEAR_destructor_object_list)) { reset($_PEAR_destructor_object_list); while (list($k, $objref) = each($_PEAR_destructor_object_list)) { $destructor = "_".get_class($objref); if (method_exists($objref, $destructor)) { $objref->$destructor(); } } // qing kong yi zhu ce de dui xiang lie biao , // fang zhi chong fu tiao yong $_PEAR_destructor_object_list = array(); }} .... register_shutdown_function("_PEAR_call_destructors"); shang mian zhe duan dai ma zhan shi le PEAR shi ru he shi xian xi gou han shu de , zai gou jian han shu zhong , jiang jian cha dang qian lei zhong shi fou you xi gou han shu , ru guo you , na me jiang ba dang qian lei de yin yong fang ru yi ge quan ju lie biao zhong , zai _PEAR_call_destructors zhong , ze jian cha zhe ge quan ju lie biao zhong de mei ge yuan su shi fou cun zai xiang ying de xi gou han shu , ru guo you , ze tiao yong ta , zui hou jiang quan ju lie biao qing kong 。 zai PEAR.php de zui hou yi xing dai ma , ze tiao yong register_shutdown_function("_PEAR_call_destructors"), zhu ce _PEAR_call_destructors, zhe yang , dang jiao ben zhi xing wan bi de shi hou ,PHP hui hui tiao zhe ge han shu 。 shi yong xi gou han shu , ni ke yi zai chu li wan yong hu de qing qiu , tui chu zhi qian zuo yi xie bi yao de " shan hou " gong zuo , dian xing de li zi shi , ni ke yi guan bi da kai de wen jian , duan kai shu ju ku de lian jie , jiang mou xie shu ju cun ru ci pan deng deng 。 cuo wu chu li PEAR zhong ke yi rang ni you hen duo de fang shi lai chu li cuo wu , ni bu jin jin shi jian dan di fan hui yi ge cuo wu dai ma , huo zhe cuo wu de xin xi , er shi ke yi fan hui yi ge PEAR_Error dui xiang , huo zhe shi you PEAR_Error pai sheng chu lai de xin de cuo wu dui xiang 。 PEAR zhong de cuo wu dui xiang de bing mei you xian ding ju ti de shu chu xing shi , ta ke yi jin jin shi bu huo cuo wu , bu gei yong hu fan hui tai duo de xin xi , ye ke yi shi qu hui tiao yi ge te shu cuo wu chu li han shu , tong shi , ji shi shu chu cuo wu xin xi , ta ye qiang po ni bi xu yao shi HTML xing shi , ni ke yi shu chu XML,CSV xing shi , huo zhe shi qi ta ni zi ji ding yi de xing shi , ni zhi xu yao cong PEAR_Error pai sheng yi ge xin de lei , ran hou zai shi dang de shi hou chuang jian bing " pao chu " zhe ge xin lei de dui xiang jiu ke yi le 。 jian dan de cuo wu chu li : zai PEAR zhong , zui jian dan de cuo wu chu li shi " pao chu " zhe ge cuo wu , ni zhi yao jian dan di chuang jian bing fan hui yi ge PEAR_Error de dui xiang jiu ke yi le 。 xia mian shi yi ge jian dan de li zi :function myconnect($host = "localhost", $port = 1080){ $fp = fsockopen($host, $port, $errno, $errstr); if (!is_resource($fp)) { return new PEAR_Error($errstr, $errno); } return $fp; } $sock = myconnect(); if (PEAR::isError($sock)) { print "connect error: ".$sock->getMessage()."\n" } ru shang mian dai ma suo zhan shi de , zai zhi xing yi duan ke neng chan sheng cuo wu de dai ma hou , ni xu yao shi yong PEAR de isError lai jian ce shi fou cun zai cuo wu , bing qie ke yi shi yong PEAR_Error de getMessage lai qu de zui jin yi ci de cuo wu xin xi 。 zhu yi : yi ding yao zai guan jian de di fang shi yong shi yong PEAR::isError shi yong raiseError PHP4.0.5 yi hou ,PEAR duo le 2 ge han shu : setErrorHandling($mode, $options = null) raiseError($message = null, $code = null, $mode = null,$options = null, $userinfo = null) qian zhe ke yi she zhi PEAR que sheng de cuo wu chu li mo shi , hou zhe shi yi ge bao zhuang han shu , fan hui yi ge PEAR_Error de dui xiang , he zhi jie chuang jian bing fan hui PEAR_Error de dui xiang lue you bu tong de shi , ru guo sheng lue $mode,$options deng shen shu , ta hui shi yong que sheng zhi lai chuang jian zhe ge PEAR_Error de dui xiang , zhe xie que sheng zhi ni ke yi shi yong setErrorHandling() lai ding zhi 。 PEAR_Error PEAR_Error shi PEAR de cuo wu dui xiang de yi ge ji lei , he PEAR bu tong , yi ban lai shuo , ni ke yi zhi jie chuang jian PEAR_Error de shi li , chuang jian fang shi : $error = new PEAR_Error($message, $code, $mode, $options, $userinfo); $message shi ni de cuo wu xin xi ,$code shi gai cuo wu de cuo wu hao , hou 3 ge shen shu shi jin mi lian xi de : $mode: shi zhe ge cuo wu de chu li mo shi , ke yi xia lie chang liang : PEAR_ERROR_RETURN: jin jin fan hui gai cuo wu dui xiang ( que sheng fang shi ) PEAR_ERROR_PRINT: zai gou jian han shu zhong da yin zhe ge cuo wu xin xi , dan shi dang qian cheng xu hui ji xu yun xing 。 PEAR_ERROR_TRIGGER: shi yong PHP de trigger_error() chu fa yi ge cuo wu , ru guo ni yi jing she zhi le cuo wu chu li han shu , huo zhe ni ba PHP de cuo wu chu li ji bie she zhi wei E_USER_ERROR, na me dang qian cheng xu jiang hui bei zhong zhi 。 PEAR_ERROR_DIE: da yin cuo wu bing tui chu , cheng xu zhong zhi 。 PEAR_ERROR_CALLBACK: shi yong yi ge hui tiao han shu huo zhe fang fa lai chu li dang qian cuo wu , cheng xu zhong zhi 。 $options: zhe ge shen shu zhi you zai $mode shi PEAR_ERROR_TRIGGER he PEAR_ERROR_CALLBACK de shi hou cai qi zuo yong , ru guo shi PEAR_ERROR_TRIGGER,$options bi xu shi E_USER_NOTICE, E_USER_WARNING huo E_USER_ERROR zhe 3 ge chang liang de yi ge , tong PHP zhong trigger_error de zhi yi zhi 。 ru guo $mode shi PEAR_ERROR_CALLBACK, $options ke yi shi yi ge zi fu chuan , nei rong shi yao hui tiao de han shu ming , ye ke yi shi yi ge 2 yuan su de shu zu , fen bie shi yi ge dui xiang bian liang , he yi ge zi fu chuan ( biao ming yao tiao yong de fang fa )。 $userinfo: cun fang fu jia de yong hu xin xi , ni ke yi ba xiang guan de tiao shi xin xi fang zai zhe li 。 PEAR_Error zhong you yi xie chang yong de fang fa , zhe xie fang fa zai PHP wen dang mei you miao shu , zhe li yi yi lie chu : int getMode: fan hui dang qian de cuo wu chu li mo shi , zheng xing 。 string getMessage: fan hui dang qian wan zheng de cuo wu xin xi , zi fu chuan 。 mixed getCallback: fan hui dang qian de hui tiao xin xi , ke neng shi suo hui tiao de han shu ming , huo zhe shi ( dui xiang , fang fa ) de shu zu 。 int getCode: fan hui zheng xing de cuo wu dai ma 。 string getType: fan hui cuo wu de lei xing , ye jiu shi dang qian de lei ming , zi fu chuan 。 string getUserInfo: fan hui fu jia de yong hu xin xi , zi fu chuan 。 string getDebugInfo: nei rong tong shang 。 string toString: fan hui dang qian dui xiang de xiang xi zi fu chuan miao shu , nei rong bao kuo cuo wu chu li de mo shi , ji bie , cuo wu xin xi , cuo wu dai ma , xiang guan hui tiao han shu deng deng 。 zong jie zhi ci , dui yu PEAR de jie shao jiu jie shu le 。 gai kuo di shuo , ru guo ni yao zuo yi ge PEAR de kuo zhan ying yong , xu yao zhe me zuo : require_once "PEAR.php" shi yong class your_pear_extend extends PEAR{} ding yi ni de xin lei 。 zai ni de lei de gou zao han shu zhong , tiao yong fu lei PEAR de gou zao han shu :function your_pear_extend{ $this->PEAR(); ... } ru guo xu yao , ding yi ni de xi gou han shu _your_pear_extend ru guo xu yao , cong PEAR_Error pai sheng chu ni zi ji de cuo wu chu li lei she zhi ni de cuo wu chu li mo shi , bing zai shi dang de shi hou chu fa cuo wu 。 zai zhi xing ke neng chan sheng cuo wu de dai ma hou , yong PEAR::isError($obj) bu huo xiang ying de cuo wu 。 shi xian ni zi ji de gong neng 。 zai PEAR gai xin fa bu li , yi jing you bu shao you xiu de ying yong mo kuai le , bi ru :PHPDoc,Cache,HTML。
󰈣󰈤
  免责声明:本文仅代表作者个人观点,与王朝网络无关。王朝网络登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述,其原创性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容、文字的真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
时尚秀气模特裴裴(8)
时尚秀气模特裴裴(7)
时尚秀气模特裴裴(6)
时尚秀气模特裴裴(5)
白墙黑瓦
广州东郊[原创]
八美至丹巴的东谷天然盆景
不一样的
 
>>返回首页<<
 
 
 为你推荐
 
 
 
 转载本文
 UBB代码 HTML代码
复制到剪贴板...
 
 热帖排行
 
 
 
 
 
©2005- 王朝网络 版权所有