定义了一个类
class myclass{ function test() echo "good";}$test1="myclass";$test2=new myclass();
你分??出那???量就知道啦
$test1只是字符串
$test2是类的实例,是个对象
对两者gettype()可以看出区别
<?phpclass MyClassq{ const constant = 'constant value'; function showConstant() { echo self::constant . "\n"; }}echo MyClassq::constant . "\n";$classname = "MyClassq";echo $classname::constant . "\n"; // PHP 5.3.0之后$class = new MyClassq();$class->showConstant();echo $class::constant."\n"; // PHP 5.3.0之后?>
复习一下“变量的变量”