[prev] [index] [next]

Equality

Because types are dynamic, some uses of == need care.

Consider strpos("abc","a") to check if 'a' occurs in 'abc'

  • strpos returns index of char in string, or false
  • the returned in index is 0, which also looks like false
  • result is ambiguous we have a problem
PHP supplies  ===  and  !==  as well as  ==  and  != 
  • == converts args to same type and compares values
  • === compares args on both type and value