PHP Data Types

PHP Data Types

Variables can store data of different types, and different data types can do different things.

PHP supports the following data types:


Finding the Data Type

To inspect the data type and value of a variable, use the var_dump() function. This is an incredibly useful function for debugging!

Example

<?php
$x = 5985;
var_dump($x);

echo "\n";

$y = "Hello"; var_dump($y); ?>

PHP NULL Value

Null is a special data type which can have only one value: NULL.

A variable of data type NULL is a variable that has no value assigned to it. If a variable is created without a value, it is automatically assigned a value of NULL.


Exercise

?

Which function is used to return the data type and value of a variable?