Create a private array property:
private $last = NULL;
private $setList = array();
In your set_a()
and set_b()
use:
$this->last = 'line A';
$this->setList['a'] = $this->last;
and
$this->last = 'line B';
$this->setList['b'] = $this->last;
Your show()
method then reads:
foreach ($this->setList as $line) {
var_dump($line);
}
or if you only need the last property set:
return $this->last;