【发布时间】:2012-01-17 07:29:06
【问题描述】:
在下面的示例中,我收到一条错误消息,指出 $foo->_test 的值不可访问,因为它是私有的。我做错了什么?
<?php
$foo = new Bar;
$foo->test();
print_r( $foo->_test );
class Foo
{
private $_test = array();
}
class Bar extends Foo
{
public function test()
{
$this->_test = 'opa';
}
}
?>
感谢任何帮助。
【问题讨论】:
-
如果我回答了您的问题,请接受。如果没有,请提出一些问题。谢谢。