PHP supports the following data types:-

  • String
  • Integer
  • Float
  • Boolean
  • Array
  • Object
  • NULL
  • Resource

String:-
A string is a string of characters and that could used in single or double quotes:-
Example:-
<?php
$x = “Hello India!”;
$y = ‘Hello India!’;

echo $x;
echo “<br>”;
echo $y;
?>
Integer:-
An integer data type is a non-decimal number between -2,147,483,648 and 2,147,483,647. An integer must have at least one digit and it could be specified in three formats: decimal (10-based), hexadecimal (16-based) or octal (8-based).
Example:-
<?php
$x = 6995;
var_dump($x);
?>
Float:-
A float is a number with a decimal point or a number in exponential form.
Example:-
<?php
$x = 11.345;
var_dump($x);
?>
Boolean:-
A Boolean symbolize two possible states: TRUE or FALSE.

$x = true;
$y = false;
Array:-
An array stores multiple values in one variable.
Example:-
<?php
$ar = array(“india”,”japan”,”china”);
var_dump($ar);
?>
NULL Value:-
Null is a special data type which could have only one value that has no value assigned to it.
Example:-
<?php
$x = “Hello India!”;
$x = null;
var_dump($x);
?>

Categories: PHP

0 thoughts on “PHP Data Types”

Leave a Reply

Latest Article

Blog

PHP Magic Methods

__get()/__set() – These are magic getters and setters for getting and putting values for class properties created dynamically. __isset() – This magic method will be invoked automatically while checking whether a required overloaded property is Read more…

Blog

WordPress Upgrade

The WordPress upgrade released time to time. We provide a WordPress upgrade, content management and maintenance services at affordable price. WordPress upgrade fixes bugs, runs cleaner, faster, and is more secure and stable. We will Read more…

Blog

Magento 2 Upload image in product

If you are trying to upload image on respective product by script then below code will help you to solve this issue. by this code you can set product thumbnail, small and large image. $objectManager Read more…