Php Data Types Tutorial
- A Datatype defines the type of data.
- For example decimal data type means number with decimal point 4545.90.
- As compared to some other programming languages in PHP we do not need to strictly define data type for data.
PHP data types are divided into two broad categories.
- Scalar Data Type: for example int, float, string and boolean
- Compound Data Type: they are container of other data types. examples of compound data types are array and object
Type Casting in PHP
PHP automatically converts data types. But, this type casting can also be enforced by using type conversion operators. Type conversion operators are simply the name of data type enclosed in normal brackets and placed before the expression.
(data type) expression;
for example
<?php
$mytype = (int) 54.99;
echo $mytype;
//will conver 54.99 to integer and will show 54
?>

