Reputation: 2360
-EDIT- Yes this actually does work. I see that now...
Is it possible to use a variable to determine a property?
I have 2 classes that are called as part of my controller
$this->document->setPageNum
and
$this->document2->setPageNum
I would like to use something like
if (is_array($pagenum)) {
$doc = 'document';
} else {
$doc = 'document2';
}
$this->$doc->setPageNum = $pagenum;
Is that possible to do?
Upvotes: 0
Views: 448
Reputation: 11987
why not save yourself the trouble of confusing code and just set the variable equal to the actual object you want, like so:
if (is_array($pagenum)) {
$doc = $this->document;
} else {
$doc = $this->document2;
}
$doc->setPageNum = $pagenum;
Upvotes: 3