Posted by Darko on 11/07/07 00:50
On Nov 6, 9:11 pm, Good Man <he...@letsgo.com> wrote:
> Darko <darko.maksimo...@gmail.com> wrote innews:1194378798.505407.6390@k79g2000hse.googlegroups.com:
>
>
>
> >> print $p->name;
> >> print $p->Name;
>
> >> The method in the class is getName, so why would "name" (lowercase)
> >> work here? All my experience in PHP says that uppercase/lowercase is
> >> vitally important!
>
> >> Here's the class:
>
> >> class Person {
>
> >> function __get($property) {
> >> $method = "get{$property}";
> >> if(method_exists($this,$method)) {
> >> return $this->$method();
> >> }
> >> }
>
> >> function getName() {
> >> return "Bob";
> >> }
>
> >> function getAge() {
> >> return 44;
> >> }
>
> >> }
>
> > It's impossible that works. You probably meant $p->getname() and $p-
> >>getName()
>
> Promise you that it does :)
>
> It's all about the __get($property) Interceptor Method :)
Right! Those fancy new methods I chose not to read when reading the
modern php manual. Knew I would regret! :)
[Back to original message]
|