PHP Data Types


 PHP is a loosely typed language. Hence we need not to declare variables as per data types. PHP automatically sets variables as per the data set.

Variables can store data of different types, and different data types can do different things.

PHP supports the following data types:

  • String
  • Integer
  • Float (floating point numbers - also called double)
  • Boolean
  • Array
  • Object
  • NULL
  • Resource

eg:


<?php
$ourcoaching_1= 3123;
$ourcoaching_2= "ourcoaching.com";
$ourcoaching_3= true;
$ourcoaching_4= 75.234;
$ourcoaching_5= 's';
$ourcoaching_6= null;

class learn {
    function learn() {
        $this->value = "i am inside learn";
    }
}
$ourcoaching_7= new learn();
	

echo $ourcoaching_1;
echo "<br>";
echo $ourcoaching_2;
echo "<br>";
echo $ourcoaching_3;
echo "<br>";
echo $ourcoaching_4;
echo "<br>";
echo $ourcoaching_5;
echo "<br>";
echo $ourcoaching_6;
echo "<br>";
echo $ourcoaching_7->value;



?>


Output:

3123
ourcoaching.com
1
75.234
s

i am inside learn


Related Tutorials