PHP has eight primitive types, but for now, we will focus on its four scalar types:
|Booleans||true or false values|
|Integers||numeric values without a decimal point, for example, 2 or 5|
|Floating point numbers or floats||numbers with a decimal point, for example, 2.3|
|Strings||characters which are surrounded by either single or double quotes, like 'this' or "that"|
<?php $number = 123; /*from w ww. j av a2 s . c om*/ var_dump($number); $number = 'abc'; var_dump($number); ?>
Here, the code first assigns the value 123 to the variable $number.
As 123 is an integer, the type of the variable will be integer int.
After that, we assign another value to the same variable, this time a string.
The type of the variable changed from integer to string, and PHP did not complain at any time.
This is called type juggling.