db.php
class db
{
public function where()
{
//code here
}
public function order()
{
//code here
}
public function limit()
{
//code here
}
}
index.php
$db = new db();
$db->where();
$db->order();
$db->limit();
如果要实现链式调用,这要在方法的结束添加return $this即可。
db.php
class db
{
public function where()
{
//code here
return $this;
}
public function order()
{
//code here
return $this;
}
public function limit()
{
//code here
return $this;
}
}
index.php
$db = new db();
$db->where()->order()->limit();
网友评论
文明上网理性发言,请遵守 新闻评论服务协议
我要评论