#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2000
    Location
    france
    Posts
    35
    Rep Power
    15
    Hi peepz !

    can a function return a boolean (true/false) that could then be directly used in a conditional loop ?

    E.g. for the moment I use the following function :

    function Check(...) {
    $q = mysql_query("select ... from ... where ...");
    if(mysql_numrows($q) == 1) { return 1; }
    else { return 0; }

    }

    and further on :

    if (Check() == 1) { ... } else { ... }

    Can't I get anything that would allow me to do :

    if (Check()) { ... } else { ... }

    ???

    Thanx

    -
    J0f
  2. #2
  3. No Profile Picture
    Apprentice Deity
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 1999
    Location
    Niagara Falls (On the wrong side of the gorge)
    Posts
    3,237
    Rep Power
    19
    That will work the way you have it.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2000
    Location
    france
    Posts
    35
    Rep Power
    15
    OK but I'm wondering if there is a way to return a boolean (like return true or return false... I dunno') so I can directly execute my function without having to compare a return to 0 or 1...

    -
    J0f
  6. #4
  7. Banned (not really)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 1999
    Location
    Brussels, Belgium
    Posts
    14,643
    Rep Power
    4492
    1=true
    0=false

    You can use either the numbers or the words, they're both the same.

    return true
    return false
    return 0
    return 1

    Then your IF statement is just like you typed.

    if(Check())
    { ...something... }
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2000
    Location
    france
    Posts
    35
    Rep Power
    15
    OK cool !
    Thanx

    -
    J0f

IMN logo majestic logo threadwatch logo seochat tools logo