Logical operators php true or false

前端 未结 4 1684
旧时难觅i
旧时难觅i 2021-01-21 09:39

As a php neewbie , I try to read a lot of other people´s code in order to learn. Today I came across a line like this :

if ( stripos($post_to_check->post_cont         


        
4条回答
  •  渐次进展
    2021-01-21 10:13

    Note: ==true and ===true are different.

    I think !==false is similar to ===true, so only explain ==true and ===true. For the first ==, it is equal in value, thus 1 == true, 0==false. for ===, it is "identical" in PHP, namely, equal in value, and also in type.

    thus, if the result is at 0th position, result should be true; however, if use ==true, it will not work as 0!= true.

    For example, stripos('a sheep', 'a') if you use ==true, the result is wrong as it is at first place.

提交回复
热议问题