The value does need to be able to be changed.
On Oct 9, 2011, at 23:37, Kevin Jensen <[email protected]> wrote: > It depends on the usage of your object's properties. If $cat is not going to > be changing you can just make it a constant of the Apple class: > > <?php > > class Apple { > const cat = "I'm a cat"; // HAS to be defined since it is a const > > public function __construct () { > $orange = new Orange(); > $orange->dog(); > } > } > > $apple = new Apple(); > > class Orange { > public function dog () { > echo Apple::cat; > } > } > > ?> > > The downside to this is where it is a constant you cannot change the value > dynamically. > > On Sat, Oct 8, 2011 at 1:52 PM, Steve Meyers <[email protected]>wrote: > >> On 10/8/11 9:03 AM, Wade Preston Shearer wrote: >>> That gets me the simplicity I want insider of dog(), but adds >>> complexity ouside of dog each time I have to call it and complicates >>> things with other variables I have to pass in. Any way to pass it in >>> automatically? I'm thinking of __set and overloading concepts but >>> haven't been able to come up with a solution. >> >> You can use $GLOBALS or global, but that's certainly not ideal. Not >> that I've never done it before.... >> >> Steve >> >> _______________________________________________ >> >> UPHPU mailing list >> [email protected] >> http://uphpu.org/mailman/listinfo/uphpu >> IRC: #uphpu on irc.freenode.net >> > > _______________________________________________ > > UPHPU mailing list > [email protected] > http://uphpu.org/mailman/listinfo/uphpu > IRC: #uphpu on irc.freenode.net _______________________________________________ UPHPU mailing list [email protected] http://uphpu.org/mailman/listinfo/uphpu IRC: #uphpu on irc.freenode.net
