[SOLVED] return false

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
stevestark5000
Forum Commoner
Posts: 61
Joined: Thu Jan 27, 2011 12:08 am

[SOLVED] return false

Post 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.
Last edited by stevestark5000 on Sun Mar 13, 2011 10:37 pm, edited 2 times in total.
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Re: return false

Post 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 {
 //...
}
stevestark5000
Forum Commoner
Posts: 61
Joined: Thu Jan 27, 2011 12:08 am

Re: return false

Post 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
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Re: return false

Post by Weirdan »

Sorry, your question just doesn't make any sense to me
stevestark5000
Forum Commoner
Posts: 61
Joined: Thu Jan 27, 2011 12:08 am

Re: return false

Post by stevestark5000 »

SOLVED. i found the answer. that i was looking for is, when return true the value is 1 and null for false
Post Reply