Double equals and tripple equals in php

后端 未结 7 461
囚心锁ツ
囚心锁ツ 2021-01-18 01:54

I searched on StackOverflow and Google and I can\'t find the answer to this question:

Should we always use the triple equal in PHP for validation?

For exampl

7条回答
  •  盖世英雄少女心
    2021-01-18 02:38

    It depends entirely on the script you're writing, there's not one correct answer for this. Having said that, there aren't many situations where you don't already know the type of the variable (except perhaps user input).

    This is the reason I stick to using == and only use === when there could be more than one type of the variable.

    The == is fine most of the time, it wouldn't have been invented if you weren't supposed to use it :)

提交回复
热议问题