NYCPHP Meetup

NYPHP.org

[nycphp-talk] lazy initialization woes

Jason Perkins jperkins at sneer.org
Thu Nov 11 10:26:08 EST 2004


On Nov 11, 2004, at 8:22 AM, Sol Toure wrote:

>> $sales_order = new sales_order;
>> $sales_order->has_a( customer );
>> print $sales_order->customer->name;
>> print $sales_order->customer->name;
>>
>> the fourth line works, because the customer object was instantiated
>> during line three (line three still fails to return a value). Does
>> anyone have any suggestions on how to get this working?
>
> Line 3 fails because you do not return anyting from __get()
> You should return " $this->$class " from your __get function call.
> Line 3 = $undifined->name;
> Line 4 succeeds because __get is not called and you have now a new
> property "$this->class" that is public by default so therefore
> accessed directly.
> Line 4 = $customer->name;

returning just the class doesn't work - I'm attempting to access an 
attribute of that class. Thanks for the reply, though.


--
Jason N Perkins




More information about the talk mailing list