SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    Non-Member
    Join Date
    Feb 2006
    Posts
    294
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Not sure of this character

    Can anyone tell me what
    PHP Code:
    if($i == "0"
    means?

    Specifcally what does the % mean?

  2. #2
    SitePoint Enthusiast
    Join Date
    Dec 2005
    Location
    B.C., Canada
    Posts
    42
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    % is the modulas operator. This is a math function. The code should be written as

    Code:
    if($i % 2 == 0)
    What you are testing is wheteher there is no remainer when some number is divided by two.

    For instance 4 % 2 == 0 but 5 % 2 == 1
    www.10-minute-rule.com
    If software can't do something useful in 10 minutes, it won't.
    wedigsports.com
    Sports news your way.

  3. #3
    always learning . . .
    Join Date
    Nov 2003
    Location
    UK
    Posts
    821
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Modulas, division remainder.

    10 % 2 would be true for your if statement where as 10 % 8 wouldn't as the remainder is 2

    beat me ^^


Bookmarks

Posting Permissions

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