[nycphp-talk] lazy initialization woes
csnyder
chsnyder at gmail.com
Wed Nov 10 23:09:02 EST 2004
You've already guessed that this is pushing the envelope in php, but
that makes it kinda cool, too.
Does this seem like a bug to anyone else? It *should* work exactly the
way you expect it to, Jason. I know that probably doesn't help right
now tonight.
Would it help to use a slightly different tack?
function __call( $class, $args ) {
if(array_key_exists( $class, $this->relationships )) {
if( $this->relationships[ $class ] == 'has_a') {
if ( isset( $this->{$class} ) ) {
return $this->{$class}->{$args[0]};
}
else {
$this->$class = new $class( $this->id );
return $this->{$class}->{$args[0]};
}
}
}
}
print $sales_order->customer('name');
More information about the talk
mailing list