第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

php中繼承Static與延遲綁定各位有什么建議?

php中繼承Static與延遲綁定各位有什么建議?

慕田峪4524236 2019-10-10 17:59:39
題目描述題目來源及自己的思路輸出Parent:parent_only=fromchild,both_distinct=fromparentChild:parent_only=fromchild,both_distinct=fromchild,child_only=fromchildhttps://www.php.net/manual/zh...相關代碼//請把代碼文本粘貼到下方(請勿用圖片代替代碼)$a=newstaticparent;var_dump(get_class_vars("staticparent"));$a=newstaticchild;echo"";var_dump(get_class_vars("staticparent"));出現(xiàn)以下結果array(2){["parent_only"]=>string(10)"fromparent"["both_distinct"]=>string(10)"fromparent"}array(2){["parent_only"]=>string(9)"fromchild"["both_distinct"]=>string(10)"fromparent"}我想咨詢下,為什么newstaticchild后父類的parent_only會被修改,而both_distinct卻不會.另外輸出的原因是什么,而且把注釋里面self::打開,替換static,結果為何是一致Parent:parent_only=fromchild,both_distinct=fromparentChild:parent_only=fromchild,both_distinct=fromchild,child_only=fromchild
查看完整描述

2 回答

?
拉風的咖菲貓

TA貢獻1995條經(jīng)驗 獲得超2個贊

因為被覆蓋了啊staticchild沒有$parent_only,所以staticchild::$parent_only調用的是staticparent的$parent_only而staticparent的$parent_only被設置了fromchild所以打印出了fromchild
另外靜態(tài)綁定不是這么用的。
子類繼承父類覆蓋了a屬性。當子類的一個實例對象調用父類一個獲取或使用a屬性方法時,一般情況下,使用的是父類的a屬性。而靜態(tài)綁定,則使用的是子類自身的a屬性。概況起來就是誰的對象用誰的
                            
查看完整回答
反對 回復 2019-10-10
?
慕仙森

TA貢獻1827條經(jīng)驗 獲得超8個贊

本來寫了一些,但是感覺我自己都要被轉暈了,可以參考這篇文章。
(PHP)Latestaticbindingandchildattributedeclaration-Blog-(BKcore)ThibautDespoulain
                            
查看完整回答
反對 回復 2019-10-10
  • 2 回答
  • 0 關注
  • 269 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網(wǎng)微信公眾號