Other Data Types
×
Home Courses Community Support
Other Data Types

Now you are familier with Integer, float and string data types. In this heading we will learn about other data types we used in PHP.

Boolean Datatype

Boolean is a data type which represent only two stas True and False. It is generally used in conditional statements where we work only for one condition either True or False.

See below code:

<?php
$var1 = true
$var2 = false
?>


In above code we have passed the values in variable. Which can be used to make decision. We will use it later in if-else statement.

Array

Array is used to store multiple values in a single variable. For example if we have a set of people named "Anuj", "Ankur" and "Anil" then we can save them in a single variable $ppl. See below code:

<?php 
$peoples = array("Anuj","Ankur","Anil");
var_dump($peoples);
?>

Output:

array (size=3)
  0 => string 'Anuj' (length=4)
  1 => string 'Ankur' (length=5)
  2 => string 'Anil' (length=4)

enlightenedPHP function var_dump(), used in above code the used to return the Datatype and it's value.


Objects

An object is a PHP function which store data along with the information how to process that data. When we use an object function, we need to declare it and a class for it.

enlightenedClass is just s structure of any object. We can mention properties and methods with in class.


See below example:

<?php
class test {
    function test() {
        $this-> value1 = "String Value";
    }
}

$obj = new test(); // creating new object
echo $obj->value1; // show object properties

?>

Output:

String Value

Pass a NULL Value

If we have any variable, holding any value. In any case if we need to use that variable but don't want the value it holds then we can assign a NULL value to the variable.

See below example-

<?php
$X = 26;
var_dump($X); //This function will show you the value of variable X
?>

Output:

int 26

Now will will pass the NULL value to variable X.

<?php
$X = 26;
$X = NULL;
var_dump($X); //This function will show you the value of variable X
?>

Output:

null


 

← Preview

Integer Float and String Data Types

Next →

Arithmetic Operators

NOTES

Our mission is to provide highly effective and quality education via innovative solutions. Geeksdemy look forward to bridge the gap between in-demand technology and academics in order to deliver innovative, easy, interesting and affordable learning across the Globe.

Courses

  • Python
  • Game Development with Unity 3D
  • Arduino
  • PCB & Circuit Designing
  • Robotics and Embedded C
  • 8051/8052 Embedded Systems
  • QuadCopter & UAV
  • MATLAB with Robotics
  • Raspberry Pi
Learn On the Go!
Get the Android App
Get the iOS App