久久久久久久视色,久久电影免费精品,中文亚洲欧美乱码在线观看,在线免费播放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 __call方法如何使用

      php __call方法是調(diào)用未定義的方法時(shí)調(diào)用的,使用語(yǔ)法如“$foo->__call('test', array(1, "2", 3.4, true))”,也就是相當(dāng)于“$foo->test(1, "2", 3.4, true)”。

      php __call方法如何使用

      推薦:《PHP視頻教程》

      php魔術(shù)方法__call的用法

      __call是調(diào)用未定義的方法時(shí)調(diào)用的。

      也就是說(shuō),你的test方法未定義,那么test這個(gè)方法名就會(huì)作為__call的第一個(gè)參數(shù)傳入,而test的參數(shù)會(huì)被裝進(jìn)數(shù)組中作為__call的第二個(gè)參數(shù)傳入。

      所以當(dāng)你調(diào)用$foo->test(1, "2", 3.4, true)時(shí),實(shí)際是相當(dāng)于調(diào)用$foo->__call('test', array(1, "2", 3.4, true))。

      __call方法在調(diào)用類的方法時(shí)觸發(fā),比如:

      <?php class google{     public function search(){         //TODO     }     public function __call($method, $parameters){         //這里的method便是對(duì)應(yīng)的方法,即"->"后面的字符串,$parameters是通過(guò)這個(gè)方法傳過(guò)來(lái)的參數(shù)     } }   $google = new google(); $keyword = 'VR'; $google->search($keyword); //當(dāng)調(diào)用當(dāng)前對(duì)象不存在的方法時(shí),會(huì)轉(zhuǎn)向__call $google->operate();

      利用__call可以做些封裝,從而調(diào)用其它對(duì)象和方法。

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