php的链式操做的理解和应用

php链式操做:相似以下实现 $db->where()->limit()->order(); 不使用链式调用时的代码格式以下:php

<?php  
namespace Database;  
  
class Database  
{  
    public function where($where)  
    {  
        return $this;  
    }  
    public function order($order)  
    {  
        return $this;  
    }  
    public function limit($limit)  
    {  
        return $this;  
    }  
      
}

代码调用以下:this

<pre name="code" class="php">//代码调用  
$db = new Database\Database();  
$db->where('...')->order('...')->limit('...');
相关文章
相关标签/搜索