Type strength in php

PHP is called a weakly typed or dynamically typed language. In most programming languages, variables can hold only one type of data, and that type must be declared before the variable can be used, as in C. In PHP, the type of a variable is determined by the value assigned to it.

For example, when you created $totalqty and $totalamount, their initial types were determined as follows:

$totalqty = 0;
$totalamount = 0.00;

Because you assigned 0, an integer, to $totalqty, this is now an integer type variable. Similarly, $totalamount is now of type float.

Leave a Comment