Check PHP variable data type with build-in function

PHP offer a very useful build-in function gettype() where you can use to check the php variable datatype. Example:

<?php
$int = 1;
echo gettype($int); //integer

$array = array(1,2,3);
echo gettype($array); //array

$string = "DEV";
echo gettype($string); //string
?>

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>