【发布时间】:2017-11-05 19:11:48
【问题描述】:
base.php:
<?php namespace MyQuestion\Base;
abstract class BaseSetting
{
public function GetValue($setting)
{
return $this->$setting;
}
}
派生的.php
<?php namespace MyQuestion\Configs;
use MyQuestion\Base;
class Settings extends BaseSetting
{
private $a = 'value 1';
private $b = 'value 2';
private $c = "value 3";
}
index.php
$abc = new Settings();
$mySettings = $abc->GetValue('a');
我尝试调试代码。 $this-> 设置中有问题。我怎样才能做到这一点?我有一些设置文件,我需要使用函数从它们中获取值。我不想在每个设置文件中定义相同的函数。
【问题讨论】:
标签: php inheritance properties derived-class base-class