From: Larry Garfield on 15 Apr 2010 22:52 On Thursday 15 April 2010 08:37:40 am Ashley Sheridan wrote: > I know I could move it to __construct and give it a default value in the > arguments list, but that brings it's own problems. What if the argument > list grows too big, and which attribute would be deemed more important > than another that you might want to override it without specifying every > other? Is there a rule of thumb as to what belongs in __construct and > what does not? > > Thanks, > Ash > http://www.ashleysheridan.co.uk I tend to favor setting the default with the property itself rather than in the constructor, even if I expect the constructor to specify it. I really really hate having undefined variables. :-) So even if, for instance, I'm going to pass in a db connection object in the constructor I will define it in the class and set it to NULL rather than not setting to anything. OK, I'm a little OCD, but it works. :-) --Larry Garfield |