Type Juggling¶
Type juggling is the emblematic PHP feature, where data has no specific type definition, and its type may change depending on the situation.
For example, integers are translated into string when displayed, or kept as integers to be used with math operations.
Type juggling is usually done automatically, without user intervention. Explicit type juggling is achieved with the cast operators.
<?php
$a = '35';
echo $a + 4; // display 39
echo substr($a, -1); // display 5
?>
See also How PHP Type Juggling Works – Explained with Code Examples, PHP Type Juggling Vulnerability and Type Juggling.
Related : Cast Operator, Boolean, Comparison, Condition, Magic Hash, Silent Behavior, String Increment, Type Checking, Type Inference, Hash Comparisons