Jump to content

basic question if statement


stijn0713

Recommended Posts

thanks!

 

if i may ask another question:

 

function current_time( $type, $gmt = 0 ) {}

 

What's the point of writing $gmt = 0 as a parameter of this function?

 

I suppose it doesn't mean it always overwrites to 0 your second parameter passed

Does it mean that you don't always need to pass gtm as a parameter to the function and in case left out, it's set 0 by the function?

 

thanks in advance

 

it meens that 0 is the default value of $gmt.  so if nothing is passed in for that when the function is called it will have a value.  it saves enforcing a refference for a fairly static value and at the same time makes the function more robust as it won't fail with an "undefined variable" warning if no value is passed in. So for this example when the function is called $type MUST be some value at runtime, but $gmt will default to 0 if value is passed in for it.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.