DataType

PHP support eight primitive datatype.four type is scalar type datatype Boolean,integer,float,string are scalar type datatype and array and object is also called compound type datatype,and finally resource and null is special type the following all datatype listed below.

     Boolean  

     Integer  

     Float  

     String  

     Array  

     Object  

     Resource  

     Null  


Boolean DataType

This is the simplest type. A boolean expresses a truth value. It can be either TRUE or FALSE.

Syntax



<?php
	$a = TRUE;
?>						
							

Example



<?php
	$test = True;
	If($true = = True)
	{
		echo “The True”;
	}
	else
	{
		echo “The False”;
	}
?>							
						
							

Integer DataType

The integer datatype it contant numbric value for example $a = 10.

Syntax



<?php
	$a = 10;
?>								
							

Example



<?php
	$test = 10;
	echo"The Value of test : " .$test; 
?>								
							

Float DataType

The floating datatype in php it contant pointing value.

Syntax



<?php
	$test = 10.01;
?>								
							

Example



<?php
	$test = 10.01;
	echo"The Value of test : " .$test; 
?>								
							

String DataType

A string is series of characters, where a character is the same as a byte. string can be as large as up to 2GB (2147483647 bytes maximum)

Syntax



<?php
	$test = 'Your String Here';
?>								
							

Example



<?php
	$test = 'Tutorials Studio';
	echo"The Value of test : " .$test; 
?>								
							

Array DataType

Array can store tree type value in array datatype like stack and queue the following syntax is beter understanding of array datatype in php.

Syntax



<?php
	array
	(
    key  => value,
    key2 => value2,
    key3 => value3,
    ...
    );
?>							
														
							

Example



<?php
	$array = arr
	(
     “one” => “ok”,
     “two” => “notok”
    );
?>								
							

Object DataType

A string is series of characters, where a character is the same as a byte. string can be as large as up to 2GB (2147483647 bytes maximum)

Example



<?php
class test
{
    function demo()
    {
        echo "Test"; 
    }
}
$bar = new test1;
$bar->demo();
?>							
							

Resource DataType

A resource is a special variable, holding a reference to an external resource. Resources are created and used by special functions.

Example


<?php
	string get_resource_type(resource$handle)
?>					
							

Null DataType

The special NULL value represents a variable with no value. NULL is the only possible value of type null.


<?php
	$test = NULL;
?>   							
							
Share Share on Facebook Share on Twitter Share on LinkedIn Pin on Pinterest Share on Stumbleupon Share on Tumblr Share on Reddit Share on Diggit

You may also like this!