国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > PHP > 正文

php基礎知識:類與對象(5) static

2024-05-04 22:14:15
字體:
來源:轉載
供稿:網友

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). 
聲明靜態的類變量和方法可以不需要實例化類對象的情況下對他們進行調用。靜態類不能被類對象調用。(類的靜態方法可以)。//注意看第一個例子,在一個非靜態的方法中調用了靜態的變量。唯一的不同是用了self。難道用了self就可以????不知道???需要一個試驗。

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. 
靜態聲明必須必須是顯式的聲明。為了兼容PHP4,如果沒有顯式聲明的對象或者方法,被當作聲明為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. 
因為靜態方法不需要實例化類對象來調用,所以偽變量$this在靜態方法中也是不可用的。 

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. 
實際上,靜態的方法調用在編譯時已經確定了。(這段我不會翻譯。???不明白???)
求了很久求來的翻譯如下:
------------------------------------------------
實際上,靜態方法的調用在編譯時解決。當使用一個明確的類名時,方法已經被完全識別而不需要應用繼承規則。如果由自身調用,那么自身被解析成當前的類,也就是代碼所屬的類。這里也沒有應用繼承規則。
但是一個新的問題:
這里不一定有繼承產生,為什么會提到繼承規則?(???不明白????)

Static properties cannot be accessed through the object using the arrow operator ->. Calling non-static methods statically generates an E_STRICT level warning. 

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 福泉市| 乃东县| 新营市| 扶余县| 玛纳斯县| 中西区| 平陆县| 黎川县| 盐山县| 珠海市| 隆德县| 界首市| 德安县| 长海县| 云南省| 盐城市| 勐海县| 壤塘县| 资阳市| 集安市| 青阳县| 湖州市| 衡山县| 永登县| 林西县| 镇赉县| 临泽县| 沁源县| 抚远县| 垣曲县| 中阳县| 荃湾区| 晋江市| 寿宁县| 长兴县| 泗阳县| 新蔡县| 南木林县| 华池县| 闽侯县| 晴隆县|