PHP Data Types Overview
Explore strings, integers, floats, booleans, and NULL in PHP.
PHP's Core Data Types
PHP supports four scalar types and several compound/special types:
- Scalar: string, int, float, bool
- Compound: array, object
- Special: NULL, resource
PHP automatically chooses the type based on context — this is called type juggling.
Strings
Strings store text. Use single or double quotes:
<?php
$single = 'Hello World'; // single — no variable parsing
$name = 'PHP';
$double = "Hello $name"; // double — variables are interpolated
echo $double; // Hello PHP
echo strlen($single); // 11All lessons in this course
- Declaring Variables in PHP
- PHP Data Types Overview
- Echo and Print Output
- Type Juggling and Type Casting