-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 con开发者_开发百科troller
$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?
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;
精彩评论