Wednesday, 28 January 2009

::, Scope Resolution Operator, in Php


The Scope Resolution Operator (also called Paamayim Nekudotayim) or in
simpler terms, the double colon, is a token that allows access to
static,
constant, and overridden
members or methods of a class.




When referencing these items from outside the class definition, use
the name of the class.


Example #1 :: from outside the class definition




<?php
class MyClass {
    const 
CONST_VALUE 'A constant value';
}

$classname 'MyClass';
echo 
$classname::CONST_VALUE// As of PHP 5.3.0

echo MyClass::CONST_VALUE;
?>






And, Static properties cannot be accessed through the object using the arrow
operator ->.

http://uk2.php.net/language.oop5.static


No comments:

My photo
London, United Kingdom
twitter.com/zhengxin

Facebook & Twitter