Print ("Version useed:". Counter: VERSION ."
");
?>
In php5, the usage of static and const keywords adds a lot of object-oriented ideas to php5. php5's object-oriented thinking is closer to Java's object-oriented thinking. Here we will describe the role of the static and const keywords in php5, and hope it will be helpful for friends who want to learn php5.
(1) static
The static keyword is in the class, describing a member is static, and static can
Vectorapp the
vector v1 is:[one,1,1,two,2,1,1] the
vector v1 (used method Insetelementat ()) is :
[one,1,three,3.9,1,two,2,1,1]
the vector v1 (used method Setelementat ()) is:
[One,1,four,3.9,1,two, 2,1,1] the
vector v1 (Useed method Removeelement ()) is: one
four 3.9 1 two 2 1 1 the
position of Object1 (top-to -botton): 3
The position of Object1 (botton-to-top): 7
The new vector (resized the vector) is:
[One,four, 3.9,1]
1 time-fol
differences between this and self, see: http://blog.csdn.net/heiyeshuwu/archive/2004/11/03/165828.aspx)
(2) const
Const is a key word that defines constants. Similar to # define in C, const can define a constant. If its value is changed in the program, an error will occur.
Example: (Note: The following code is from phpe.net)
Copy codeThe Code is as follows: Class Counter
{
Private static $ count = 0; // defines a static attribute
Const VERSION = 2.0; // define a constant
// Constructor
Function
class, it does not belong to any object instance, and other classes cannot be accessed. It is shared only to the instance of the class and can be fully protected by the program. Static variables of the class are very similar to global variables and can be shared by all class instances. Static Methods of the class are also the same, similar to global functions. The static method of the class can be used to initialize the static attributes of the class. In addition, static members must use self f
keyword is in the class, describing a member is static, static can restrict external access, because the static member belongs to the class, it does not belong to any object instance, and other classes cannot be accessed. it is shared only to the instance of the class and can be fully protected by the program. Static variables of the class are very similar to global variables and can be shared by all class instances. static methods of the class are also the same, similar to global functions. Th
, please refer to: http://blog.csdn.net/heiyeshuwu/archive/2004/11/03/165828.aspx)
(2) const
A const is a keyword that defines a constant, similar to a # define in C, that defines a constant, and an error occurs if its value is changed in the program.
Illustrate the above code: (Note: The following code is from Phpe.net)
Copy the Code code as follows:
Class Counter{private static $count = 0;//defines a static propertyConst VERSION = 2.0;//defines a constantconstructor functionfunction __con
defines a constant, and an error occurs if its value is changed in the program.
Illustrate the above code: (Note: The following code is from Phpe.net)
Class Counter
{
private static $count = 0;//defines a static property
Const VERSION = 2.0;//defines a constant
constructor function
function __construct ()
{
Self:: $count;
}
Destructors
function __destruct ()
{
Self:: $count--;
}
To define a static method
static function GetCount ()
{
Return self:: $count;
}
}
Create an instance
$c = new Coun
same, similar to global functions. The static method of the class can visit the static attributes of the class. In addition, it is clarified that static members must use self to visit and this will cause errors.
(2) const
Const is the key word for defining constants. similar to # define in C, const can define a constant. if its value is changed in the program, an error is displayed.
The above code is illustrated as an example: (Note: The following code comes from phpe.net)
Class Counter{Priva
)Class Counter{private static $count = 0;//defines a static propertyConst VERSION = 2.0;//defines a constantconstructor functionfunction __construct (){Self:: $count;}Destructorsfunction __destruct (){Self:: $count--;}To define a static methodstatic function GetCount (){Return self:: $count;}}Create an instance$c = new Counter ();Perform printingPrint (Counter::getcount (). "n "); Use the direct input class name to access the static method Counter::getcountPrint the version of the classPrint ("V
between this and self, see: http://blog.csdn.net/heiyeshuwu/archive/2004/11/03/165828.aspx)(2) constConst is a key word that defines constants. Similar to # define in C, const can define a constant. If its value is changed in the program, an error will occur.Example: (Note: The following code is from phpe.net)Copy codeThe Code is as follows:Class Counter{Private static $ count = 0; // defines a static attributeConst VERSION = 2.0; // define a constant// ConstructorFunction _ construct (){Self:
not belong to any object instance, and other classes cannot be accessed. It is shared only to the instance of the class and can be fully protected by the program. Static variables of the class are very similar to global variables and can be shared by all class instances. Static Methods of the class are also the same, similar to global functions. The static method of the class can be used to initialize the static attributes of the class. In addition, static members must use self for access. If t
static member belongs to the class, is not belong to any object instances, other classes are inaccessible, only to the class instance share, Can be a certain procedure to protect the members. A static variable of a class, very similar to a global variable, can be shared by instances of all classes, and the static method of the class is the same, similar to the global function. Static methods of a class can access the static properties of a class. Additionally, static members must be accessed us
according to the following formula:HWM = useed byte = Total bytes-unused BlocksTotal bytes and unused blocks can be extracted using show_space.HWM information can also be obtained through analyze tables. The Dba_tables view contains columns that you can use for each table spatial analysis. Where blocks represents unused space for blocks that have been used, i.e. hwm,empty_blocks.3.2.2 HWM Space Utilization InformationTo compare the block number of bl
error will occur. The above code is illustrated as an example:
The code is as follows:
Class Counter{Private static $ count = 0; // defines a static attributeConst VERSION = 2.0; // define a constant// ConstructorFunction _ construct (){Self: $ count ++;}// DestructorFunction _ destruct (){Self: $ count --;}// Define a static methodStatic function getCount (){Return self: $ count;}}// Create an instance$ C = new Counter ();// Execute printPrint (Counter: getCount ()."\ N "); // use the dire
methods of the class are also the same, similar to global functions. The static method of the class can be used to initialize the static attributes of the class. In addition, static members must use self for access. if this is used, an error occurs.
(For the similarities and differences between this and self, see: http://blog.csdn.net/heiyeshuwu/archive/2004/11/03/165828.aspx)
(2) const
Const is a key word that defines constants. similar to # define in C, const can define a constant. if its val
# define in C, const can define a constant. If its value is changed in the program, an error will occur.Example: (Note: The following code is from phpe.net)
Class Counter{Private static $ count = 0; // defines a static attributeConst VERSION = 2.0; // define a constant// ConstructorFunction _ construct (){Self: $ count;}// DestructorFunction _ destruct (){Self: $ count --;}// Define a static methodStatic function getCount (){Return self: $ count;}}// Create an instance$ C = new Counter ();// E
access. if this is used, an error occurs.
(For the similarities and differences between this and self, see: http://blog.csdn.net/heiyeshuwu/archive/2004/11/03/165828.aspx)
(2) const
Const is a key word that defines constants. similar to # define in C, const can define a constant. if its value is changed in the program, an error will occur.
Example: (Note: The following code is from phpe.net)
The code is as follows:
Class Counter{Private static $ count = 0; // defines a static attributeConst
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.