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
- Type Juggling
- How I Chained Mass Assignment + PHP Type Juggling to Take Over Any Account on a Live Platform