$this->valid = (FALSE !== reset($this->array)); What does this syntax mean?

Discussion in 'PHP' started by aayybb, Jun 10, 2010.

  1. #1
    Hi,

    I am not familiar with the following syntax which has ( ) at the right side of = , and it has !== inside of ( ). Can any body explain it to me? Thanks for any help in advance.

    $this->valid = (FALSE !== reset($this->array));
     
    aayybb, Jun 10, 2010 IP
  2. stephan2307

    stephan2307 Well-Known Member

    Messages:
    1,277
    Likes Received:
    33
    Best Answers:
    7
    Trophy Points:
    150
    #2
    OK !== means this the same as != with the difference that it will also compare the type. Now you need to remember that TRUE and FALSE can also be represented by 1 and 0.

    So what this person does here is to double check that the return from the reset is unequal to FALSE. if he would have done != and reset function returns 0 it would think it is the same.

    The person has put brackets around it as the brackets will return true or false just like when using if condition
     
    stephan2307, Jun 10, 2010 IP
  3. aayybb

    aayybb Peon

    Messages:
    128
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Let me see if I understand this totally.

    If reset($this->array) is true then it is not equal to FALSE (statement is true) then the $this->valid will be true.
    If reset($this->array) is false then it is equal to FALSE (statement is false) then the $this_valid will be false.
     
    aayybb, Jun 10, 2010 IP
  4. stephan2307

    stephan2307 Well-Known Member

    Messages:
    1,277
    Likes Received:
    33
    Best Answers:
    7
    Trophy Points:
    150
    #4
    yep. as far as I can tell
     
    stephan2307, Jun 10, 2010 IP
  5. aayybb

    aayybb Peon

    Messages:
    128
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Thank you.
     
    aayybb, Jun 10, 2010 IP