茄子在线看片免费人成视频,午夜福利精品a在线观看,国产高清自产拍在线观看,久久综合久久狠狠综合

    <s id="ddbnn"></s>
  • <sub id="ddbnn"><ol id="ddbnn"></ol></sub>

  • <legend id="ddbnn"></legend><s id="ddbnn"></s>

    CodeIgniter連貫操作的底層原理分析
    來源:易賢網(wǎng) 閱讀:1106 次 日期:2016-08-22 14:34:16
    溫馨提示:易賢網(wǎng)小編為您整理了“CodeIgniter連貫操作的底層原理分析”,方便廣大網(wǎng)友查閱!

    本文分析了CodeIgniter連貫操作的底層原理。分享給大家供大家參考,具體如下:

    php oop連貫操作原理

    ->符號其實是傳遞對象指針的?;蛟S這么說是不對的。

    但是,我們可以這么的理解。

    不多說。放代碼。

    普通用法:

    <?php

    class test

    {

     public $a='';

     public $b='';

     public function actiona() {

      $this->a="hello";

      return $this;

     }

     public function actionb() {

      $this->b="world";

      return $this;

     }

     public function actionc() {

      echo $this->a." ".$this->b;

     }

    }

    $oktest=new test();

    $oktest->actiona();

    $oktest->actionb();

    $oktest->actionc();

    ?>

    連貫用法:

    <?php

    class test

    {

     public $a='';

     public $b='';

     public function actiona() {

      $this->a="hello";

      return $this;

     }

     public function actionb() {

      $this->b="world";

      return $this;

     }

     public function actionc() {

      echo $this->a." ".$this->b;

     }

    }

    $oktest=new test();

    $oktest->actiona()->actionb()->actionc();

    ?>

    看到了沒有。

    連起來了??梢园巡僮鞔饋?。

    看起來直觀多了。閱讀代碼時也輕松了很多。

    類里面操作都返回了一個指針。

    $this.

    他等價于你初始化的那個對象 $oktest

    所以下面的操作可以連續(xù)起來。

    試著去掉每個操作里的

    return $this

    你將會看到錯誤提示。

    例子:

    <?php

    class sql{

     public $select;

     public $from;

     public $where;

     public $order;

     public $limit;

     public function from($_from='FROM test') {

     $this->from=$_from;

     return $this;

     }

     public function where($_where='WHERE 1=1') {

     $this->where=$_where;

     return $this;

     }

     public function order($_order='ORDER BY id DESC') {

     $this->order=$_order;

     return $this;

     }

     public function limit($_limit='LIMIT 0,30') {

     $this->limit=$_limit;

     return $this;

     }

     public function select($_select='SELECT *') {

     $this->select=$_select;

     return $this->select." ".$this->from." ".$this->where." ".$this->order." ".$this->limit;

     }

    }

    $sql =new sql();

    echo $sql->from()->where()->order()->limit()->select();

    ?>

    希望本文所述對大家基于CodeIgniter框架的PHP程序設計有所幫助。

    更多信息請查看網(wǎng)絡編程
    易賢網(wǎng)手機網(wǎng)站地址:CodeIgniter連貫操作的底層原理分析

    2026上岸·考公考編培訓報班

    • 報班類型
    • 姓名
    • 手機號
    • 驗證碼
    關于我們 | 聯(lián)系我們 | 人才招聘 | 網(wǎng)站聲明 | 網(wǎng)站幫助 | 非正式的簡要咨詢 | 簡要咨詢須知 | 新媒體/短視頻平臺 | 手機站點 | 投訴建議
    工業(yè)和信息化部備案號:滇ICP備2023014141號-1 云南省教育廳備案號:云教ICP備0901021 滇公網(wǎng)安備53010202001879號 人力資源服務許可證:(云)人服證字(2023)第0102001523號
    聯(lián)系電話:0871-65099533/13759567129 獲取招聘考試信息及咨詢關注公眾號:hfpxwx
    咨詢QQ:1093837350(9:00—18:00)版權所有:易賢網(wǎng)