如果不是bug,为什么没有输出


if it is not bug then why there is no output

我声明的类只有一个对象。使用该对象调用method是可以的,但是调用非对象的方法不会导致输出。这里演示了<>之前//定义简单类类人{函数say_hello ($ name = '世界'){Echo "hello {$name}";

            }
        }
        $instant1 = new Person();
        $object2 = new Person();
        echo get_class($object2);
        ?>
<br/>
<?php 
if(is_a($object2,'Person'))
{
//remeber to pass arguments 
echo "This object or instant is in that class";
}
else {
echo "No dude :( ";
}
?>

<?php 

$instant1->say_hello('Paritosh');
echo " <br/>";

ob -> say_hello ();//没有错误,没有输出,即使没有对象名称为$ob,下面的代码没有运行//是bug还是什么概念?

echo "No output ";
object2 -> say_hello ();

?>

之前我在webmatrix平台的IIS Express中使用PHP 5.2.17版本。

$ object不是Person,那么解释器如何知道您想要访问Person?如果您想在没有对象的情况下访问函数,请尝试:

Person::say_hello();