Main PHP Data Types
This is A quick post to understand datatypes in the PHP
and those are complex to understand are only included below with little explanation. :)
PHP supports the following data types:
- String
- Integer
- Float
(floating point numbers - also called double)
- Boolean
- Array
- Object
- Resource
- NULL
Integer
mainly, It is a number between -2,147,483,648 and +2,147,483,647.
Boolean
A Boolean shows two possible states: TRUE or FALSE.
$a = true;
$b = false;
$b = false;
Booleans are mostly used in conditional testing.
Array
to stores multiple
values in one single variable.
PHP NULL Value
Null is a special data type which can have only one value, NULL.
A variable of data type NULL,no value
assigned to it.
Note: If a
variable, without a value, it is automatically assigned a value of
NULL.
Variables can also be emptied by setting the value to NULL:
Example
<?php
$a = "Hello universe.!";
$b = null;
var_dump($a);
?>
$a = "Hello universe.!";
$b = null;
var_dump($a);
?>
Resource
not an actual data type. It stores the reference of functions and external resources to PHP.
Example: database call.
No comments:
Post a Comment