国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

PHP實(shí)現(xiàn)鏈?zhǔn)讲僮鞯脑碓斀?/h1> Original 2016-12-29 09:37:10 169

abstract:下面小編就為大家?guī)?lái)一篇PHP實(shí)現(xiàn)鏈?zhǔn)讲僮鞯脑碓斀?。在一個(gè)類中有多個(gè)方法,當(dāng)你實(shí)例化這個(gè)類,并調(diào)用方法時(shí)只能一個(gè)一個(gè)調(diào)用,類似:db.php<?php   class db { public function where() { //code here } public function order() { //code

下面小編就為大家?guī)?lái)一篇PHP實(shí)現(xiàn)鏈?zhǔn)讲僮鞯脑碓斀狻?/p>

在一個(gè)類中有多個(gè)方法,當(dāng)你實(shí)例化這個(gè)類,并調(diào)用方法時(shí)只能一個(gè)一個(gè)調(diào)用,類似:

db.php

<?php
 
class db
{
public function where()
{
//code here
}
public function order()
{
//code here
}
public function limit()
{
//code here
}
}

   

index.php

<?php
 
$db = new db();
 
$db->where();
$db->order();
$db->limit();

   

如果要實(shí)現(xiàn)鏈?zhǔn)秸{(diào)用,這要在方法的結(jié)束添加return $this即可。

db.php

<?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

<?php
 
$db = new db();
 
$db->where()->order()->limit();

 更多關(guān)于PHP實(shí)現(xiàn)鏈?zhǔn)讲僮鞯脑碓斀庹?qǐng)關(guān)注PHP中文網(wǎng)(m.miracleart.cn)其它文章! 


Release Notes

Popular Entries