Skip to content
Advertisements

Value operations for data types in PHP

boolval () : Returns the boolean data type value of any variable content.
intval () : Returns the integer data type value of any variable content.
floatval () : Returns the double data type value of any variable content.
doubleval () : Returns the value of the double data type of the contents of any variable.


intval()

$Value = 8.55;
$ValueDataType = gettype($Value);

echo "Content : " . $Value . "<br />";
echo "Data Type : " . $ValueDataType . "<br /><br />";

echo "Content : " . intval($Value) . "<br />";
$ValueDataType	=	gettype($Value);
echo "Data Type : " . $ValueDataType;

Content : 8.55
Data Type : double

Content : 8
Data Type : int


boolval()

example 1:

$Value = 8.55;
$ValueDataType = gettype($Value);

echo "Content : " . $Value . "<br />";
echo "Data Type : " . $ValueDataType . "<br /><br />";

echo "Content : " . boolval($Value) . "<br />";
$ValueDataType	=	gettype($Value);
echo "Data Type : " . $ValueDataType;

Content : 8.55
Data Type : double

Content : 1
Data Type : boolean

example 2:

$Value	=array();
$ValueDataType	= gettype($Value);

echo "Content : <br /><pre>";
print_r($Value);
echo "</pre>";
echo "Data Type : " . $ValueDataType . "<br /><br />";

echo "Content : " . boolval($Value) . "<br />";
$LastDataType	=	gettype($Value);
echo "LastDataType : " . $LastDataType;

Array ( )
Data Type : array

Content : 
LastDataType : boolean


intval()

$Value	= "True codes";
$ValueDataType	= gettype($Value);

echo "Content : " . $Value . "<br />";
echo "Data Type : " . $ValueDataType . "<br /><br />";

echo "Content : " . intval($Value) . "<br />";
$LastDataType	=	gettype($Value);
echo "Data Type : " . $LastDataType;

Content : True codes
Data Type : string

Content : 0
Data Type : int


doubleval ()

$Value	= 12224;
$ValueDataType = gettype($Value);

echo "Content : " . $Value . "<br />";
echo "Data Type : " . $ValueDataType . "<br /><br />";

echo "Content : " . doubleval($Value) . "<br />";
$LastDataType	=	gettype($Value);
echo "Data Type : " . $LastDataType;

Content : 12224
Data Type : integer

Content : 12224
Data Type : double

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: