1 不能夠定義靜態變量(常量除外)
2 定義的常量 const YOUCONST = VALUE,不能在子類中覆蓋,在子類中以 interfaceName::YOUCONST的方式調用
3 不能使用parent::YOUCONST的方式調用接口的常量
類:
1 const 變量可以使用parent::YOUCONST的方式,className::YOUCONST的方式在子類中訪問
2 const定義的變量,在子類中可以被覆蓋
3 當然在類中可以定義靜態成員變量了
示例:
<?php
interface TestInterface
{
const CONSTVAR = 'aaa';
static staticvar = 111;
public function alert($str);
}
class TestClass implements TestInterface
{
const CONSTVAR = 'bbb';
public function __CONSTRUCT()
{
echo TestInterface::CONSTVAR;
}
public function alert($str)
{
echo $str;
}
public function __DESTRUCT()
{
}
}
$test1 = new TestClass();
?>