PHP: How to use gettype variable function [example]

Leave a Comment


  • Return the type of php variable.
  • Possible return value are boolean, integer, double, string, array, null, object resources, user function.


Syntax :
String gettype(mixed $var)

Example
<?php
echo gettype(102).'<br/>';    //return integer
echo gettype(true).'<br/>;     //return  boolean
echo gettype(' ').'<br/>';   //return string
echo gettype(null).'<br/>';       //return null
echo gettype(array()).'<br/>';       //return array
echo gettype(new stdclass()).'<br/>';       //return object
?>

0 comments:

Post a Comment