时间:2021-07-01 10:21:17 帮助过:7人阅读
在类定义外使用的话,使用类名调用。在PHP 5.3.0,可以使用变量代替类名。
程序运行结果:
Fruit Color Red
showColor(); ?>
程序运行结果:
Fruit::showColor() Apple::showColor()
color;
}
}
class Banana
{
public $color;
public function __construct()
{
$this->color = "Banana is yellow";
}
public function GetColor()
{
return Apple::showColor();
}
}
$banana = new Banana;
echo $banana->GetColor();
?>
程序运行结果:
Banana is yellow
程序运行结果:
show color
http://www.bkjia.com/PHPjc/752410.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/752410.htmlTechArticle双冒号操作符即作用域限定操作符Scope Resolution Operator可以访问静态、const和类中重写的属性与方法。 在类定义外使用的话,使用类名调用。...