我使用范围解析运算符来使用Foo类的printItem(),现在我的查询就是当我们可以使用这个功能时,创建对象有什么用?何时在适当的编码环境中使用范围解析运算符.
<?PHP class Foo { public function printItem($string) { echo "This is in class Foo ". $string ."<br />"; } public function printPHP() { echo "PHP is great "."<br />"; } } class Bar extends Foo { public function printItem($string) { echo "This is in class Bar ". $string ."<br />"; } } //$foo = new Foo; $bar = new Bar; $bar->printPHP(); $bar->printItem("Bar class object"); //Foo::printItem("Mental Case");