View Full Version : Very Basic Function Question.

03-01-2012, 02:44 AM
How can I write a function, and then use an if statement to do something if the function returns true?

I basically want to write a function that consists of at if else statement. I want the if to return false and the else to return true. Then I want to write an if else statement that says something like..

If the function returns true then do this, else do this.

Am I making any sense?

03-01-2012, 03:15 AM
function your_function($var)
if($var = 'something'){
$x = true;
} else {
$x = false;
return $x;

$result = your_function($var);

Then $variable will hold either true or false. Not sure if you need to pass a variable to the function but obviously change this as you need.

And then if you wanted to do something with the result.

if($result = true) {

} else {