Casting in PHP is the process of converting a value from one data type into another. This is often necessary when you receive data as a string (from a form) but need to perform calculations on it as an integer or float.
You can cast a variable by using the following keywords before the variable name:
(int) - Cast to Integer(string) - Cast to String(float) - Cast to Float(bool) - Cast to Boolean(array) - Cast to ArrayThis converts floats (by removing decimals) or numeric strings into whole numbers.
Converting numbers or booleans into strings is useful for display or concatenation.
Most values cast to true. Values that cast to false include 0, "0", empty strings, and NULL.