锟洁常锟斤拷

锟斤拷锟皆帮拷锟斤拷锟斤拷锟斤拷始锟秸憋拷锟街诧拷锟斤拷锟街碉拷锟斤拷锟轿拷锟斤拷锟斤拷锟斤拷诙锟斤拷锟斤拷使锟矫筹拷锟斤拷锟斤拷时锟斤拷锟斤拷要使锟斤拷 $ 锟斤拷锟脚★拷

锟斤拷锟斤拷锟斤拷值锟斤拷锟斤拷锟斤拷一锟斤拷锟斤拷值锟斤拷锟斤拷锟斤拷锟角憋拷锟斤拷锟斤拷锟斤拷锟斤拷锟皆o拷锟斤拷学锟斤拷锟斤拷慕锟斤拷锟斤拷锟斤拷锟斤拷锟矫★拷

锟接口o拷interface锟斤拷锟斤拷也锟斤拷锟皆讹拷锟藉常锟斤拷锟斤拷锟斤拷锟斤拷示锟斤拷锟斤拷锟侥碉拷锟叫碉拷锟接匡拷锟斤拷锟街★拷

锟斤拷 PHP 5.3.0 锟金,匡拷锟斤拷锟斤拷一锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷态锟斤拷锟斤拷锟洁。锟斤拷锟矫憋拷锟斤拷锟斤拷值锟斤拷锟斤拷为锟截硷拷锟街o拷锟斤拷 self锟斤拷parent 锟斤拷 static锟斤拷锟斤拷

Example #1 锟斤拷锟斤拷锟绞癸拷锟揭伙拷锟斤拷喑o拷锟�

<?php
class MyClass
{
    const 
constant 'constant value';

    function 
showConstant() {
        echo  
self::constant "\n";
    }
}

echo 
MyClass::constant "\n";

$classname "MyClass";
echo 
$classname::constant "\n"// 锟斤拷 5.3.0 锟斤拷

$class = new MyClass();
$class->showConstant();

echo 
$class::constant."\n"// 锟斤拷 PHP 5.3.0 锟斤拷
?>

Example #2 锟斤拷态锟斤拷锟斤拷示锟斤拷

<?php
class foo {
    
// 锟斤拷 PHP 5.3.0 锟斤拷
    
const bar = <<<'EOT'
bar
EOT;
}
?>

锟斤拷 heredoc 锟斤拷同锟斤拷nowdoc 锟斤拷锟斤拷锟斤拷锟斤拷锟轿何撅拷态锟斤拷锟斤拷锟叫★拷

Note:

Nowdoc 支锟斤拷锟斤拷锟斤拷 PHP 5.3.0 锟斤拷锟斤拷锟侥★拷