久久久久久久视色,久久电影免费精品,中文亚洲欧美乱码在线观看,在线免费播放AV片

<center id="vfaef"><input id="vfaef"><table id="vfaef"></table></input></center>

    <p id="vfaef"><kbd id="vfaef"></kbd></p>

    
    
    <pre id="vfaef"><u id="vfaef"></u></pre>

      <thead id="vfaef"><input id="vfaef"></input></thead>

    1. 站長(zhǎng)資訊網(wǎng)
      最全最豐富的資訊網(wǎng)站

      PHP SPL 標(biāo)準(zhǔn)庫(kù)之 Countable

      PHP SPL 標(biāo)準(zhǔn)庫(kù)之 Countable

      本文實(shí)例講述了PHP標(biāo)準(zhǔn)庫(kù) (SPL)——Countable用法。分享給大家供大家參考,具體如下:

      類實(shí)現(xiàn) Countable 可被用于 count() 函數(shù).

      接口摘要

      Countable { /* 方法 */ abstract public count ( void ) : int }

      當(dāng)一個(gè)類實(shí)現(xiàn)了Countable接口,實(shí)現(xiàn)了接口中的count方法,即可直接使用count(Object)的到count方法返回的值。

      例:

      class MyCount  {  private $num;   public function __construct($num)   {  $this->num = $num;  }   public function count()   {  return $this->num;  } }  $obj = new MyCount(10);  echo count($obj);//返回1

      上面的結(jié)果在意料之中,但是顯然不是我們想要的結(jié)果,接下來實(shí)現(xiàn)Countable接口再試一次:

      class MyCount implements Countable {  private $num;   public function __construct($num)   {  $this->num = $num;  }   public function count()   {  return $this->num;  } }  $obj = new MyCount(10);  echo count($obj);//返回10

      實(shí)現(xiàn)Countable接口后,使用count()即可觸發(fā)類中count方法,從而得到了返回的10。

      推薦教程:《PHP》

      贊(0)
      分享到: 更多 (0)
      網(wǎng)站地圖   滬ICP備18035694號(hào)-2    滬公網(wǎng)安備31011702889846號(hào)