Implicit and Explicit Casting

PHP is a loosely typed language that allows you to declare a variable and its type simply by using it. It also automatically convert values from one data type to another whenever required. This is called implicit casting.

For example:
echo $c;
But what if we had wanted $c to be an integer instead?There are various ways in which we could achieve this,one of which is to force the result of $a/$b to be cast to an integer value using integer cast type(int),like this:
this is called explicit casting.

PHP’s cast types

Type Cast
Translate »