SyntaxStudy
Sign Up
PHP Beginner 1 min read

PHP Data Types

PHP Data Types

TypeExample
String"hello"
Integer42
Float3.14
Booleantrue, false
Array[1, 2, 3]
NULLnull

Use gettype() to get a variable's type. Use is_int(), is_string() etc. to test.

Example
<?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)
?>