久久久久久久视色,久久电影免费精品,中文亚洲欧美乱码在线观看,在线免费播放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. 站長資訊網(wǎng)
      最全最豐富的資訊網(wǎng)站

      php對魔術(shù)方法的認識

      php對魔術(shù)方法的認識:1、【_set】屬性不存在時自動設(shè)置屬性;2、【__get】屬性不存在或不能讀取時,設(shè)置該方法可讀??;3、【__call】方法不存在時,執(zhí)行;4、【__callStatic】靜態(tài)方法不存在時,執(zhí)行。

      php對魔術(shù)方法的認識

      php對魔術(shù)方法的認識:

      1、_set:屬性不存在時自動設(shè)置屬性

      /** * 屬性不存在時通過__set自動設(shè)置屬性 * @param $key [鍵名] * @param $value [屬性值] */ function __set($key,$value){ $this->arr[$key] = $value; }   代碼: $object->title = 'blue'; //設(shè)置不存在的屬性,調(diào)用__set() echo $object->title,'<br/>'; //輸出不存在的屬性,調(diào)用__get()   輸出: blue

      2、__get:屬性不存在或不能讀取時,設(shè)置該方法可讀取

      /** * 屬性不存在或不能讀?。▽傩詾樗接衟rivate)時,通過__get讀取 * @param $key 鍵名 * @return 屬性 */ function __get($key){ return $this->arr[$key]; }

      3、__call:方法不存在時,執(zhí)行

      /** * 方法不存在時,執(zhí)行__call方法 * @param $func [方法名] * @param $param [參數(shù)] * @return [description] */ function __call($func,$param){ var_dump($func); echo '<br/>'; var_dump($param); echo '<br/>'; }   代碼: $object -> show('hello','world'); //調(diào)用不存在的方法,調(diào)用__call()   輸出: string(4) "show" array(2) { [0]=> string(5) "hello" [1]=> string(5) "world" }

      4、__callStatic:靜態(tài)方法不存在時,執(zhí)行

      /** * 靜態(tài)方法不存在時,執(zhí)行__callStatic方法 * @param $func [方法名] * @param $param [參數(shù)] * @return [description] */ static function __callStatic($func,$param){ var_dump($func); echo '<br/>'; var_dump($param); echo '<br/>'; }   代碼: IMoocObject::show('hello','world'); //調(diào)用不存在的靜態(tài)方法,調(diào)用__callStatic()   輸出: string(4) "show" array(2) { [0]=> string(5) "hello"  [1]=>string(5) "world" }

      5、__toString:當對象轉(zhuǎn)換為字符串時,執(zhí)行

      /** * 當對象轉(zhuǎn)換為字符串時,執(zhí)行__toString方法 * @return string [description] */ function __toString{ return __CLASS__; }   代碼: echo $object,'<br/>'; //將對象以字符串形式輸出,調(diào)用__toString()   輸出: IMoocObject

      6、__invoke:當把對象當成函數(shù)來使用時,執(zhí)行

      /** * 當把對象當成函數(shù)來使用時,執(zhí)行__invoke方法 * @param [type] $param [參數(shù)] * @return [type] [description] */ function __invoke($param){ var_dump($param); }   代碼: echo $object('hello'); //將對象當函數(shù)使用,調(diào)用__invoke()   輸出: string(5) "hello"

      相關(guān)免費學習推薦:php編程(視頻)

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