1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

whats the correct usage of 'or' in the if function

Discussion in 'Development' started by rektpixel, Jan 2, 2018.

  1. rektpixel

    rektpixel Baby Zombie

    Messages:
    186
    I have this code:
    PHP:
                                        if($gamecount==or or or or or or or or or or 10 or 11)
                                            
    $player->setFood(20);
    but I know it's very wrong. It just doesn't look right. Is there a way to get all the numbers from 0 to 11 without using or? something like:
    PHP:
                                        if($gamecount==0-11)
                                            
    $player->setFood(20);
    but I'm pretty sure that's also wrong.
     
  2. xZeroMCPE

    xZeroMCPE Witch

    Messages:
    67
    GitHub:
    xZeroMCPE
    You could use:

    Code:
    if($gamecount >= 0 && $gamecount < 12){
    
    }
    This allows the range to be 0 - 11 and cannot surpass it.
     
    Levi likes this.
  3. rektpixel

    rektpixel Baby Zombie

    Messages:
    186
    thanks!
     
  4. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
    Don't read PHP as a human. Read it as a machine.
    == means "equal". This is different from the English "is". In English, "is" is followed by a description of the subject, so "he is a person" does not mean "he" == "a person", but that "he" has the attributes of "a person". "I am SOFe" means "I" satisfies the definition of "SOFe", but "I" is not equal to "SOFe" (and much less "PEMapModder" is equal to "SOFe").
     
  5. Indexfire

    Indexfire Baby Zombie

    Messages:
    137
    GitHub:
    Indexfire
    Tldr PHP cant understand you like a living human can (unless the human is a dumbo that is)
     
  6. Indexfire

    Indexfire Baby Zombie

    Messages:
    137
    GitHub:
    Indexfire
    I thought it was || doing && checks for both variables
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.