뒤펌쌘--잚돨쓰檄냥逃

2018-09-07 12:01

阅读:738

  /*
+-------------------------------------------------------------------------------+
=굶匡槨Haohappy뗍<<CorePHPProgramming>>
=櫓ClassesandObjects寧覽돨궝션
=럇陋槨寮+몸훙懃돤
=槨긁출옵콘랙?骸캉뺑罔さ컫冗냘閏窕ぴ?剋剋
=뻑短툽팀寧攣,句寡뵨杰唐PHP갖봤諒묾谿쏵꼍!
=PHP5桔씩櫓懃:
+-------------------------------------------------------------------------------+
*/


뒤펌쌘--잚돨쓰檄냥逃

잚돨쓰檄냥逃宅寧겹돨잚냥逃꼇谿:쓰檄냥逃宅뚤蹶돨茄절轟밑,怜宅잚굶?盞橘?儉쳬痰윱茄君잚狼룐陋돨묘콘뵨鑒앴,뎃꼇관윅景땍뚤蹶돨묘콘뵨鑒앴.쓰檄냥逃관윅쓰檄렘랬뵨쓰檄橄昑.

쓰檄橄昑관벵瞳잚櫓狼룐陋돨鑒앴,옵鹿譚杰唐잚돨茄절묾權.茄셥??뇜죄橄黨寧몸미땍돨잚깻掘齡련狂렘駕棍,잚돨쓰檄橄昑렷끽잚慨黨변鑒돨홍애긴좆

乖쳬瞳苟절櫓賈痰죄寧몸쓰檄橄昑Counter::$count.劍橄黨Counter잚,랍꼇橄黨훨부Counter돨茄절.콱꼇콘痰this윱多痰劍,뎃옵鹿痰self샀페劍唐槻돨츱츰깊댐.瞳절綾櫓,getCount렘랬럿쀼self::$count,랍꼇角Counter::$count.

쓰檄렘랬橙茄君잚矜狼룐陋돨묘콘,宅景땍돨뚤蹶轟밑.쓰檄렘랬렷끽잚慨黨홍애변鑒.쓰檄렘랬옵鹿供홍련狂잚돨橄昑,冷옵鹿譚뚤蹶돨茄절윱련狂,꼇쬠련狂돨掘땍刀角뤠角痂척.

瞳6.3절櫓,getCount角寧몸팹繫돨렘랬,痰->윱딧痰.PHP쉔접寧몸this긴좆,쐴밗렘랬청唐賈痰돕.뎃角,getCount꼇橄黨훨부뚤蹶.瞳唐硅헙워苟,乖쳬?芻죕M祜梶뺨然朴契㏊캘冬饌굘洞촉?컸척앎壇맡賈痰쓰檄렘랬.PHP쉥꼇瞳쓰檄렘랬코꼬쉔접this긴좆,섦賈콱닖寧몸뚤蹶櫓딧痰劍쳬.

절綾6.7譚6.3맣긴getCount槨쓰檄렘랬랍윱.Static밑숩俚꼇콘羸岺寧몸茄절痰->頓炬륜윱딧痰getCount,뎃PHP쉥꼇瞳렘랬코꼬쉔접this긴좆.흔벎콱賈痰this->윱딧痰,쉥삔놔댄.

//6.3절寧뒤愷쌘--뭐芚변鑒뵨驕뭐변鑒櫓돨절綾(꽝였품匡),繫법좃몸절綾돨궐싹,콱옵鹿붤봤廊壞
//static렘랬宅팹繫렘랬裂쇌돨혐깎.

콱옵鹿畇寧몸렘랬繫법털뙤this角뤠쉔접윱鞫刻角뤠劍굳쓰檄뒈샀諒렷쓰檄뒈딧痰.뎠횔,흔벎콱痰죄static밑숩俚,꼇밗劍等湳굳딧痰,侶몸렘랬悧角쓰檄돨.

콱돨잚冷옵鹿땍屢끽좆橄昑,꼇矜狼賈痰publicstatic,怜矜狼痰const밑숩俚섦옵.끽좆橄昑悧角쓰檄돨.劍쳬角잚돨橄昑,랍꼇角茄절뺏맡잚돨뚤蹶돨橄昑.

Listing6.7Staticmembers


릿齡덜쯤 덜쯤흔苟:<?php
classCounter
{
privatestatic$count=0;
constVERSION=2.0;

function__construct()
{
self::$count++;
}

function__destruct()
{
self::$count--;
}

staticfunctiongetCount()
{
returnself::$count;
}
};

//눼쉔寧몸茄절,橙__construct()쉥獵契
$c=newCounter();

//渴놔1
print(Counter::getCount().<br>\n);

//渴놔잚돨경굶橄昑
print(Versionused:.Counter::VERSION.<br>\n);
?>


评论


亲,登录后才可以留言!