Jump to content

basic question if statement


Recommended Posts

probably a very stupid question, but i pose it because it's counterintuitive for me to write it:


i find in alot of wordpress code if statements like:


if ( false === $var)


i suppose it's the same as if ( $var === false) ? why would one right it in the first way?

Link to comment
Share on other sites



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


Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • 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.