class Test {
private $foo = 'var';
private $hoge = 'piyo';
private $fuga = 'fugafuga';
public function output($key) {
echo $this->{$key};
}
}
$test = new Test();
$test->output('hoge');
$test->output('huga');
結果:
piyofugafuga
class Test {
private $foo = 'var';
private $hoge = 'piyo';
private $fuga = 'fugafuga';
public function output($key) {
echo $this->{$key};
}
}
$test = new Test();
$test->output('hoge');
$test->output('huga');
piyofugafuga