Is the identical sign used only in PHP? If not, which languages have this sign?
No, it’s used at least in Javascript also, perhaps in other languages of dynamic and weak typing.
The ==
compares the values in the best possible effort, if the types of each operand are different the language tries to make them compatible to be able to make the comparison. That can bring undesired results.
The ===
consider the type and no coercion is made. If the types are different it is already ensuring that the result will be different and the value is only evaluated if the types are equal.
If so, why?
PHP is a language of script, was made to "facilitate" the rapid creation of code and the programmer did not have to worry about certain details, so that made sense. Today language tries to stop being script, but you need to maintain compatibility, so you get this kind of schizophrenic thing.
If C and Java have it, because it is not so well known/taught along with the other signs?
This is characteristics of weak typing languages where a value can be passed as if it were of another type. Java is not like this.
C is like that, but in a slightly different way, usually you don’t try to do conversions, it just tries to access and raw memory. They never found it necessary to have an operator of "identical" in C because the philosophy of language is to let access anyway. But today almost all compilers, at least optionally, produce warnings when this occurs by forcing the programmer to use a cast to indicate that the intention is to use one type as if it were another.
It is very rare for a language to have static and weak typing, C is so because it is considered a portable assembly.
Even dynamic typing languages opt for strong typing, case of Python, Moon, Harbour, etc..
Operator == and === in Javascript. Weak typing language uses this carrier to know if the value and type comparison are equal in strong typing languages.
– rray
Related or Duplicate? : Way to make a comparison between three variables
– novic