Page 1 of 1

[SOLVED] return false

Posted: Sun Mar 13, 2011 9:17 pm
by stevestark5000
I am having problems understanding return true and return false. If a value is returned false then how to code it to tell what to do next? what exactly is the difference of the return true and false?

Code: Select all

<?php
function mySum($numX, $numY){
    $total = $numX + $numY;
    if ($number<=0){
      return false;
    } else {     
      return true; 
      } 
}
?>
after then code returned false, what do i do next to get the returned value? can i have a small tutor on how to get the value of a return false or return true? or what is the difference when i use them like that.

Re: return false

Posted: Sun Mar 13, 2011 9:22 pm
by Weirdan

Code: Select all

$val = mySum(2,3); // store return value into a variable
print(mySum(2,3)); // use return value as an argument for another function
if (mySum(2,3)) { // make a decision based on the return value
 //...
} else {
 //...
}

Re: return false

Posted: Sun Mar 13, 2011 9:24 pm
by stevestark5000
yes but i need to know when to use return true and return false and how to get the values on them afterwards

Re: return false

Posted: Sun Mar 13, 2011 9:35 pm
by Weirdan
Sorry, your question just doesn't make any sense to me

Re: return false

Posted: Sun Mar 13, 2011 10:37 pm
by stevestark5000
SOLVED. i found the answer. that i was looking for is, when return true the value is 1 and null for false