1

Topic: Function question

Just a quickie. smile If one creates a function like follows:

function test_function($value = false)
{
    if ($value)
    {
        [run this command]
    }
}

Would that command only be executed if some value was passed to that function within the ()?


Cheers. smile

Re: Function question

It's optional, so it'll run with or without any arguments.

Re: Function question

Matt: If you mean will test_function() (as opposed to test_function(true)) make the if statement true, then no, it won't.

4 (edited by MattF 2008-04-05 19:48)

Re: Function question

elbekko wrote:

It's optional, so it'll run with or without any arguments.

That's where I've been going wrong then. big_smile What would be the way to make it run only if a specific value was passed, but not complain about a missing argument if none was supplied?

Thanks again. smile

Re: Function question

What you're doing. tongue
test_function() does not run the command
test_function(false) does not run the command
test_function(true) runs the command

When Bekko said run, he meant the function.

6

Re: Function question

Smartys wrote:

What you're doing. tongue
test_function() does not run the command
test_function(false) does not run the command
test_function(true) runs the command

When Bekko said run, he meant the function.

So I have the basics correct then. big_smile That must mean I'm mucking things up elsewhere, within the command itself, or the logic behind it.

You ever notice that when you're having one of those days, everything conspires against you? big_smile