標籤:php初學者
今日課程:PHP開發-零基礎到精通瘋狂實戰教程(第二季)【韋瑋老師】
1.繼承與封裝的實戰
650) this.width=650;" src="https://s5.51cto.com/wyfs02/M01/9E/16/wKioL1mLA7OhnXfwAAJQC6lsV_E638.png-wh_500x0-wm_3-wmp_4-s_1010879185.png" title="QQ圖片20170809204539.png" alt="wKioL1mLA7OhnXfwAAJQC6lsV_E638.png-wh_50" />
/*封裝*/class woman{var $name;var $age;private $money;//給money賦值function setm($b){$this->money=$b;}function money1(){echo ‘my money is‘.($this->money).‘<br>‘;}}$a = new woman();$a ->name;//$a ->money;無法訪問//$a ->money1();可以正常訪問//$a ->money1();無法訪問$a ->setm(999);$a ->money1();
650) this.width=650;" src="https://s5.51cto.com/wyfs02/M01/9E/18/wKiom1mLH_LBzm3vAALNTjmksRQ956.png-wh_500x0-wm_3-wmp_4-s_973176229.png" title="QQ20170809224608.png" alt="wKiom1mLH_LBzm3vAALNTjmksRQ956.png-wh_50" />
/*繼承*/class woman{var $name;var $age;function ect(){echo "i can eat<br>";}}class man extends woman{function sing(){echo ‘i cam sang<br>‘;}}class ren extends man{}$a = new man();$a -> ect();$a -> sing();$b = new ren();$b -> ect();$b -> sing();
650) this.width=650;" src="https://s4.51cto.com/wyfs02/M00/9E/19/wKiom1mLIteynvkeAAKL5DweihA050.png-wh_500x0-wm_3-wmp_4-s_1308139122.png" title="QQ20170809225808.png" alt="wKiom1mLIteynvkeAAKL5DweihA050.png-wh_50" />
/*重載*/class woman{var $name;var $age;function eat(){echo "i can eat<br>";}}class ren extends woman{function eat(){echo ‘i can 大口吃<br>‘;}}$a = new ren();$a -> eat();//重載方法
本文出自 “一條大大大大廢魚” 部落格,謝絕轉載!
翻身的廢魚——論PHP從入門到放棄需要多久?19