Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4

Thread: booleon problem

  1. #1
    Regular Coder
    Join Date
    Dec 2007
    Posts
    269
    Thanks
    28
    Thanked 0 Times in 0 Posts

    booleon problem

    PHP Code:
    $c true;
    if (
    $c'false'){
        echo 
    "false";
    }else{
        echo 
    "true";

    even if $c is TRUE or FALSE output is FALSE why ? (in IE and FF too)

  • #2
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    You are trying to compare $c to a string which you can't do and you aren't using the proper comparison operator (===). Try this
    PHP Code:
    $c true;
    if (!
    $c){ // if $c is false
        
    echo "false";
    }else{
        echo 
    "true";

    or
    PHP Code:
    $c true;
    if (
    $c === false){ // if $c is false
        
    echo "false";
    }else{
        echo 
    "true";

    Read the manual on comparison operators. http://us2.php.net/operators.comparison
    Last edited by _Aerospace_Eng_; 02-29-2008 at 03:14 PM.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • Users who have thanked _Aerospace_Eng_ for this post:

    zodehala (02-29-2008)

  • #3
    Regular Coder
    Join Date
    Dec 2007
    Posts
    269
    Thanks
    28
    Thanked 0 Times in 0 Posts
    many many thanx

  • #4
    Senior Coder rafiki's Avatar
    Join Date
    Aug 2006
    Location
    Floating around somewhere...
    Posts
    2,046
    Thanks
    19
    Thanked 42 Times in 42 Posts
    using $c = 'false' in your if statement you are setting it to 'false' not checking,
    = is set
    == is compare value
    === is compare value and type

  • Users who have thanked rafiki for this post:

    zodehala (02-29-2008)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •