Casting PHP types is not easier as it seems. Type juggling in PHP is not obvious. In Java variables can always be represented as strings, without throwing errors. This is not the case with PHP and I’ve not found the detailed behavior of string casting in the official documentation. Here it is. Scalar types (boolean, integer, float, and…