gettype() in php

Like other programming languages, php does not requires any  variable declaration so we can move freely with php datatypes.

To view the datatype of the variable  use  gettype() function

Eg1:

<?php
$name="HELLO";
echo "Name:".$name;
echo "<br/>";
echo "Datatype:".gettype($name);
?>

OUTPUT 1:

Name:HELLO
Datatype:string

Eg 2:


<?php
$value=25;
echo "Value:".$value;
echo "<br/>";
echo "Datatype:".gettype($value);
?>;

OUTPUT 2 :

Value:25
Datatype:integer

Posted in Php Tagged with: ,