四虎精品视频-四虎精品成人免费网站-四虎黄色网-四虎国产视频-国产免费91-国产蜜臀97一区二区三区

php基礎(chǔ)知識(shí):類與對(duì)象(5) static

Declaring class members or methods as static makes them accessible without needing an instantiation of the class. A member declared as static can not be accessed with an instantiated class object (though a static method can). 
聲明靜態(tài)的類變量和方法可以不需要實(shí)例化類對(duì)象的情況下對(duì)他們進(jìn)行調(diào)用。靜態(tài)類不能被類對(duì)象調(diào)用。(類的靜態(tài)方法可以)。//注意看第一個(gè)例子,在一個(gè)非靜態(tài)的方法中調(diào)用了靜態(tài)的變量。唯一的不同是用了self。難道用了self就可以????不知道???需要一個(gè)試驗(yàn)。

The static declaration must be after the visibility declaration. For compatibility with php4, if no visibility declaration is used, then the member or method will be treated as if it was declared as public. 
靜態(tài)聲明必須必須是顯式的聲明。為了兼容php4,如果沒有顯式聲明的對(duì)象或者方法,被當(dāng)作聲明為public。

Because static methods are callable without an instance of the object created, the pseudo variable $this is not available inside the method declared as static. 
因?yàn)殪o態(tài)方法不需要實(shí)例化類對(duì)象來調(diào)用,所以偽變量$this在靜態(tài)方法中也是不可用的。 

In fact static method calls are resolved at compile time. When using an explicit class name the method is already identified completely and no inheritance rules apply. If the call is done by self then self is translated to the current class, that is the class the code belongs to. Here also no inheritance rules apply. 
實(shí)際上,靜態(tài)的方法調(diào)用在編譯時(shí)已經(jīng)確定了。(這段我不會(huì)翻譯。???不明白???)
求了很久求來的翻譯如下:
------------------------------------------------
實(shí)際上,靜態(tài)方法的調(diào)用在編譯時(shí)解決。當(dāng)使用一個(gè)明確的類名時(shí),方法已經(jīng)被完全識(shí)別而不需要應(yīng)用繼承規(guī)則。如果由自身調(diào)用,那么自身被解析成當(dāng)前的類,也就是代碼所屬的類。這里也沒有應(yīng)用繼承規(guī)則。
但是一個(gè)新的問題:
這里不一定有繼承產(chǎn)生,為什么會(huì)提到繼承規(guī)則?(???不明白????)

Static properties cannot be accessed through the object using the arrow operator ->. Calling non-static methods statically generates an E_STRICT level warning. 
靜態(tài)成員不能被類的對(duì)象通過箭頭符號(hào)->來調(diào)用。靜態(tài)的調(diào)用一個(gè)非靜態(tài)方法會(huì)導(dǎo)致一個(gè)E_STRICT級(jí)別的警告。

靜態(tài)成員例:
復(fù)制代碼 代碼如下:class Foo 

   public static $my_static = 'foo';  
   public function staticValue() { 
       return self::$my_static;//注意這里!!!! 
       //return $my_static;//這樣寫會(huì)不會(huì)出錯(cuò)。需要試驗(yàn) 
   } 


class Bar extends Foo 

   public function fooStatic() { 
       return parent::$my_static;//注意這里!!!! 
   } 

print Foo::$my_static . " n"; 
$foo = new Foo(); 
print $foo->staticValue() . " n"; 
print $foo->my_static . " n";      // 未定義的"Property" my_static  
// $foo::my_static is not possible 
print Bar::$my_static . " n"; 
$bar = new Bar(); 
print $bar->fooStatic() . " n"; 

靜態(tài)方法例: 
class Foo { 
   public static function aStaticMethod() { 
       // ... 
   } 

Foo::aStaticMethod(); 

php技術(shù)php基礎(chǔ)知識(shí):類與對(duì)象(5) static,轉(zhuǎn)載需保留來源!

鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標(biāo)記有誤,請(qǐng)第一時(shí)間聯(lián)系我們修改或刪除,多謝。

主站蜘蛛池模板: 二年级我是谁课文| 超薄轻舞玉女女裤广场舞| 吻胸亲乳激情大尺度| 萱草花合唱谱二声部| 黄网站免费在线看| 全球高考图片| 戚薇夫妇现身机场| 摇曳山庄的幽灵| 雳剑 电视剧演员表| 狂魔电影| 最贵的烟前十名| 周秀娜与罗仲谦新婚吻戏合集| 我们的快乐人生 电视剧| 禁忌的爱在线| 肮脏性感的人| 韩漫画未删减男同| 误杀2剧情详细介绍| 疑云密布| 生死搏斗| 2025最好运头像| 天下第一楼结局| 国产伦理女村支书| 韩国一级免费| 在线抖音| 天津电视台体育频道节目单| 坚强的理由吉他谱| 艳窟神探| 香港之夜在线观看免费版香港电影| 女子监狱第五季| 睡衣派对| 古建凉亭生产厂家| 被抛弃的青春1982| 白培中| 普通日记200字可抄| 无尽的华尔兹| 我和我的祖国 五线谱| 玛丽·杜布瓦| 蜘蛛夫人:超感觉醒 电影| 正在恋爱中 电视剧韩剧免费全集结局| 夫妻性生活视屏| 一场风花雪月的事电影|