-3

I have a big confusion over equal to operators(==.===), below I mentioned php code where checking condition that string "all" equal to numeric 0. But it returns true at double equal to ("all"==0), but not with others:

<?php    
    var_dump("all"==0);
    var_dump("all"=="0");
    var_dump("all"==="0");
    var_dump("all"===0);    
?>

Output:

bool(true) 
bool(false)
bool(false) 
bool(false) 

for all the condition the answer should be false. but why "all"==0 is true. can anyone explain?

Manoj
  • 41
  • 8
  • When 0 is alive it is numeric and when 0 is in "(double quote) it defines as a string. – TarangP Mar 14 '18 at 08:55
  • please under the question before marking duplicate. and give a correct solution and refrence for this before marking duplicate. – Manoj Mar 14 '18 at 10:27

1 Answers1

0
=== is Identical operator which performs a 'typesafe comparison'.

That means that it will only return true if both operands have the same type and the same value.

Rp9
  • 1,855
  • 2
  • 18
  • 28
  • 1
    The question has already been flagged with three duplicates. Please read the comments – Rotimi Mar 14 '18 at 08:57
  • yes, i agree but when i checked the condition of double equal to `("all" ==0)` it should be `false`.. instead of that getting `true` as result. can you please explain me the reason? This question may duplicate but no one is explain why `("all"==0)` is `true` .. in that question i mentioned 4 possibilities output. for all condition should be false is output. except ` "all"==0` i'm not good in English. i apologise for any grammatical mistake. – Manoj Mar 14 '18 at 10:22