Four scalar types of PHP
String
String is used for binary data. This can be text, content of an image file etc.
$today = 'hey how are you';
Int
For numeric values, Int is used. Int can contain a positive or a negative number.
$total = 20000000;
$temperature = -14 ;
Float
Float is used for numbers that have a fractional component. Float can also contain positive or negative values.
$length = 145.78;
$growthRate = -5.216;
Sometimes name Double is used for Float values.
Boolean
Boolean is used for values that are either true or false. You would often see Boolean values in conditional statements.
if (($age > 12) && ($age < 20)) {
$teenage = true;
} else {
$teenage = false;
}
//Some content goes here
if ($teenage) {
}
Copyright © 2026 eLLeNow.com All Rights Reserved.