PHP如何实现静态的链式调用
Db::table('**')->where('***','***')->order('***')->find('**'); 想这种应该怎么实现
public function table() { return new self(); }
示例:
<?php class Db { public $table; public $a; public $b; public static function table($table) { $db = new static; $db->table = $table; return $db; } public function where($a, $b) { $this->a = $a; $this->b = $b; return $this; } } Db::table('abc')->where('a', 'b');
来源:https://segmentfault.com/q/1010000019451768/
优质内容筛选与推荐>>