I googled for this for quite awhile. I think I am missing some big concept, but I can't figure out why this won't work
//SomeClass.php
class SomeClass
{
protected $something;
public function __construct() {
$this->something = 'password';
}
public function test() {
return ($this->something);
}
}
//OtherClass.php
require_once('SomeClass.php');
class OtherClass extends SomeClass
{
public function __construct() {
echo parent::test();
}
}
What is the deal here?
您应该在调用parent :: test()之前先调用parent :: __ construct()。
构造函数不得返回任何值。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.