How to Use Variables and Data Types in PHP (A Clear Guide for Absolute Beginners) Part 1
The first thing you need to understand when learning PHP is variables and data types.
In this guide, we will see how variables work and what types of data PHP can store.
What is a Variable in PHP
The variable is used to store and manipulate data in your PHP scripts.
The variable must start with a $ sign.
Followed by a letter or underscore _.
Can not contain spaces.
Variable names are case-sensitive, so $age is not the same as $Age.
$sayHello = "Hello World";
echo $sayHello;
Type 1 - String
The string is a text inside quotes.
$message = "PHP is still alive";
Type 2 - Integer
The integer is simply a number.
$year = 2025;
Type 3 - Float
The Float is simply a decimal number.
$temperature = 36.5;
Type 4 - Boolean
The Boolean is simply true or false.
$isActive = true;