PHP Data Types
| Type | Example |
|---|---|
| String | "hello" |
| Integer | 42 |
| Float | 3.14 |
| Boolean | true, false |
| Array | [1, 2, 3] |
| NULL | null |
Use gettype() to get a variable's type. Use is_int(), is_string() etc. to test.
| Type | Example |
|---|---|
| String | "hello" |
| Integer | 42 |
| Float | 3.14 |
| Boolean | true, false |
| Array | [1, 2, 3] |
| NULL | null |
Use gettype() to get a variable's type. Use is_int(), is_string() etc. to test.
<?php
$str = "Hello";
$int = 42;
$flt = 3.14;
$bool = true;
$null = null;
$arr = [1, "two", 3.0];
echo gettype($str); // string
echo gettype($int); // integer
echo is_int($int); // 1 (true)
echo is_string($str); // 1 (true)
var_dump($bool); // bool(true)
?>