Default Arguments

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
Default Arguments: what's the general consensus about them? To give an
example, so we're all on the same page, this is the syntax I'm talking

function foo($bar = "some value"){

So, in the past when I was programming with PHP a lot, I found myself
using default arguments more and more because they were so convenient.
But in the back of my mind, something about them seemed
somewhat...sloppy. I've never had the privilege of working on a
project quite large enough for architectural weaknesses to really show
their strain, so I'd like to pose this question to other minds, to see
if any of you have input about this syntactical tool.


Re: Default Arguments

Quoted text here. Click to load it

misconception major...number 1

Quoted text here. Click to load it

it's a convenience. if i have a function that has umphteen args and they
don't have default values, i have to have an ugly mess of '', '' or null,
null, null or whatever. it is much cleaner only supplying arguments that are
ACTUALLY needed. it's stupidity not to.

Re: Default Arguments wrote:
Quoted text here. Click to load it

I think default arguments are fine if you have a specific default
argument to pass.  It just helps keep the code cleaner.

Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.

Re: Default Arguments

Quoted text here. Click to load it

I just wish php supported named arguments too.

Site Timeline