我有以下一段代码,它不起作用:
<?php
class test{
public static $var = 'foo';
public static function printvar(){
echo "Var value is {self::$var}";
}
}
test::printvar();
?>
但是,这有效:
<?php
class test{
public static $var = 'foo';
public static function printvar(){
echo "Var value is " . self::$var;
}
}
test::printvar();
?>
问题是,无论如何我可以从静态方法内部访问引号内的静态变量吗?