PHP supports several data types that describe the kind of data a variable can hold. PHP is loosely typed, so you don't need to declare the data type explicitly.
true or false.PHP automatically determines the data type of a variable based on the value assigned to it. This behavior is known as dynamic typing.
Type anything below to see how PHP would interpret its data type (Simulated):
Try: 123, 45.67, true, null, or Hello
// Demonstrating common PHP data types using var_dump
<?php
$txt = "Hello PHP";
$num = 123;
$price = 99.99;
$is_active = true;
$colors = array("red", "green", "blue");
$empty = null;
var_dump($txt);
var_dump($num);
var_dump($price);
var_dump($is_active);
var_dump($colors);
var_dump($empty);
?>
The var_dump() function displays both the data type and value of each variable, helping developers understand how PHP interprets different values.
Mentally trace how PHP assigns data types automatically when values change. Try changing a variable from a number to text and observe the new output using var_dump().
var_dump() or gettype() to inspect variable types.===) when type matters.datatypes.php.var_dump() to display their type and value.