Posted by Kimmo Laine on 12/17/47 11:53
"Greg Scharlemann" <greg.scharlemann@gmail.com> wrote in message
news:1152569290.266969.99400@75g2000cwc.googlegroups.com...
> Finally, another somewhat semi-related newbie question. I come from a
> java background with getter and setter methods. I modified the Test
> class David created with what I thought is a getter method, however it
> doesn't work... The function just prints: "()" PHP is not as straight
> forward as I hoped...
> print "testing->getTestBool() = $testing->getTestBool()";
> ?>
This is evaluated actually like this would be :
'testing->getTestBool() = '.$testing->getTestBool.'()';
and since you have not property getTestBool, $testing->getTestBool returns
nothing. therefore it's "testing->getTestBool() = ".[nothing]."()"; that's
why it prints only the empty parenthesis.
Functions are not executed within strings (you'd have to be using eval but
you don't want that). So you need to execute the getter method outside the
string:
print "testing->getTestBool() = " . $testing->getTestBool();
--
"ohjelmoija on organismi joka muuttaa kofeiinia koodiksi" -lpk
spam@outolempi.net | Gedoon-S @ IRCnet | rot13(xvzzb@bhgbyrzcv.arg)
Navigation:
[Reply to this message]
|