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.
This is the simplest type. A boolean expresses a truth value. It can be either TRUE or FALSE.
<?php
$a = TRUE;
?>
<?php
$test = True;
If($true = = True)
{
echo “The True”;
}
else
{
echo “The False”;
}
?>
The integer datatype it contant numbric value for example $a = 10.
<?php
$a = 10;
?>
<?php
$test = 10;
echo"The Value of test : " .$test;
?>
The floating datatype in php it contant pointing value.
<?php
$test = 10.01;
?>
<?php
$test = 10.01;
echo"The Value of test : " .$test;
?>
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)
<?php
$test = 'Your String Here';
?>
<?php
$test = 'Tutorials Studio';
echo"The Value of test : " .$test;
?>
Array can store tree type value in array datatype like stack and queue the following syntax is beter understanding of array datatype in php.
<?php
array
(
key => value,
key2 => value2,
key3 => value3,
...
);
?>
<?php
$array = arr
(
“one” => “ok”,
“two” => “notok”
);
?>
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)
<?php
class test
{
function demo()
{
echo "Test";
}
}
$bar = new test1;
$bar->demo();
?>
A resource is a special variable, holding a reference to an external resource. Resources are created and used by special functions.
<?php
string get_resource_type(resource$handle)
?>
The special NULL value represents a variable with no value. NULL is the only possible value of type null.
<?php
$test = NULL;
?>