I would like to know on what condition PHP decides when to convert from String to Integer and the other way around
Example:
$key = 0;
$test = \'test
It converts strings to numbers when either operand is a number. The manual puts it cryptically like this:
http://php.net/manual/en/language.operators.comparison.php
For various types, comparison is done according to the following table (in order).
Operand 1 Operand 2 null or string string Convert NULL to "", numerical or lexical comparison ... string, resource string, resource Translate strings and resources or number or number to numbers, usual math
Note that the "in order" part is important when reading this table.