You are here: Re: Passing Boolean to a Function « PHP Programming Language « IT news, forums, messages
Re: Passing Boolean to a Function

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация