PHP Data Types
PHP data types describe the kind of value stored in a variable.
What is it?
PHP data types describe the kind of value stored in a variable.
Why do we use it?
Understanding data types helps you perform correct operations.
How does it work?
PHP determines the current type from the value stored in a variable.
Syntax
$name = "AIFA"; $age = 20; $price = 99.50; $active = true;
Example
<?php $name = "AIFA"; $age = 20; $price = 99.50; $active = true; var_dump($name); var_dump($age); var_dump($price); var_dump($active); ?>
Example Explained
More Examples
<?php $data = null; var_dump($data); ?>
⚠️ Important Rules
Common types include string, integer, float, boolean, array, object and null.
❌ Common Mistakes
Assuming every numeric-looking value has the same type.
🌍 Real-World Use
Forms, databases, APIs and calculations depend on correct value types.
📝 Practice Exercise
Create variables using string, integer, float, boolean and null.
💻 Try It Yourself
Write and run this PHP lesson inside the AIFA Coding Lab.