Data Types
PHP types: string, int, float, bool, array, object, null. var_dump shows a value and its type, and gettype returns the type name. PHP converts types automatically in many places, so use strict comparison === to avoid surprises.
Example
var_dump("hi");
var_dump(42);
var_dump(3.14);
var_dump(true);
var_dump(null);
var_dump([1, 2]);
echo gettype(5.0), "\n";
var_dump("5" == 5);
var_dump("5" === 5);Result
string(2) "hi"
int(42)
float(3.14)
bool(true)
NULL
array(2) {
[0]=>
int(1)
[1]=>
int(2)
}
double
bool(true)
bool(false)Exercise
Show a value and its type.
(42);Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.