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 2 of 2

Thread: Advanced If

  1. #1
    Regular Coder
    Join Date
    Dec 2007
    Posts
    145
    Thanks
    5
    Thanked 5 Times in 5 Posts

    Advanced If

    How could I correctly format this?

    Code:
    if($num > 10 || $num == 10 && $num < 20 || $num == 20) {
    
    }

    I intend for at least one on each side of the && symbol to prove true.

    Thanks!
    Last edited by nobackseat88; 10-18-2009 at 03:35 PM.

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,863
    Thanks
    160
    Thanked 2,224 Times in 2,211 Posts
    Group them like
    PHP Code:
    if(($num 10 || $num == 10 )&& ($num 20 || $num == 20)) {


    to override the priority of && over ||

    Or simply
    PHP Code:
    if($num >= 10 && $num <= 20 ) {


    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)


  •  

    Posting Permissions

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