PHPV 5中的另一个重要的新功能是支持对类使用静态成员和方法。
Another important addition to PHP V5 is support for static members and methods on classes.
现在您已经了解了有关静态方法和成员的增强,现在让我们看一看PHPV 5中新添的类,它们构成了非常有用的部分:标准php库。
Now that we have seen some enhancements with static methods and members, let's take a look at some new classes added to a very useful part of PHP V5: the Standard PHP Library.
PHPV5.3提供一些特性来增强对类的静态成员和方法的支持。
PHP V5.3 has added several features to enhance the support for static members and methods within a class.
改进静态方法和成员处理。
我把数字变成是Classifier 2类中的成员变量,这将允许我避免将其作为参数传递给一大堆静态方法。
I've made the number a member variable within the Classifier2 class, which allows me to avoid passing it around as a parameter to a bunch of static methods.
支持导入常量:这个特性使静态方法和字段能够被导入,这样在访问静态成员时就不必使用完全限定的类名。
Support for importing constants: This facility allows static methods and fields to be imported, avoiding the need to use fully qualified class names when accessing static members.
一个成员声明为static,那么他是不可以被这个类的实例来访问的(虽然静态方法可以)。
A member declared as static can not be accessed with an instantiated class object (though a static method can).
Modifier类提供了静态方法和常量来对类和成员访问修饰符进行编码。
The Modifier class provides static methods and constants to decode class and member access modifiers.
声明类里的静态类成员或者静态方法可以是这些类成员或者方法在不实例化的情况下直接被访问。
Declaring class members or methods as static makes them accessible without needing an instantiation of the class.
基本上,静态成员实施的对象如何,以及他们如何改变?和他们只能进行静态方法?
Basically, how are static members implemented in objects, and how do they change? And can they only be manipulated with static methods?
比起将整个类别宣告为静态,以一些静态成员宣告非静态类别是较典型的方法。
It is more typical to declare a non-static class with some static members, than to declare an entire class as static.
两种方法改变静态成员的值是正确的,但是第一种方法会给你一个警告,第二不会。
No, a static variable can be manipulated by any method that has access to it.
通过在子类中增加一个静态同步方法来试图保护父类中的静态成员变量是无效的。
It is not effective to add a new static synchronized method in a subclass that attempts to protect static fields declared in a superclass.
通过在子类中增加一个静态同步方法来试图保护父类中的静态成员变量是无效的。
It is not effective to add a new static synchronized method in a subclass that attempts to protect static fields declared in a superclass.
应用推荐