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 6 of 6
  1. #1
    Regular Coder
    Join Date
    Jul 2002
    Location
    The Netherlands
    Posts
    252
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How to check whether a value equals 0?

    Hi,

    I just can't seem to figure out how to check whether a perticular value equals '0' as in zero. This is the code that I have now, but this off course always returns false.

    Code:
    if($operator == "=" && $origial == $value) $parse = true;
    Any ideas on how to do this?

    Thanx, Michiel

  • #2
    Regular Coder
    Join Date
    Aug 2004
    Location
    The US of A
    Posts
    767
    Thanks
    1
    Thanked 0 Times in 0 Posts
    if ($value == "0") { code }

  • #3
    Regular Coder
    Join Date
    Jul 2002
    Location
    The Netherlands
    Posts
    252
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Okay,

    that simple ...

    and this code would also work with alpha numeric values, I suppose?

    Cheers, Michiel

  • #4
    New Coder
    Join Date
    Feb 2004
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts
    In fact it's even simpler as long as you know you're dealing with integers (e.g. not with an HTML form), you don't even need the quotes around the zero as it's an integer.
    Last edited by kliqster; 10-19-2004 at 01:48 AM.

  • #5
    Regular Coder trib4lmaniac's Avatar
    Join Date
    Feb 2004
    Location
    Cornwall, UK
    Posts
    535
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Or even
    PHP Code:
    if(!$value// do stuff 

  • #6
    Senior Coder
    Join Date
    Aug 2003
    Location
    One step ahead of you.
    Posts
    2,815
    Thanks
    0
    Thanked 3 Times in 3 Posts
    The way to see if the variable is a true 0 (integer)
    PHP Code:
    <?
    if($variable === 0)
    {
        
    // do something
    }
    ?>


  •  

    Posting Permissions

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