How to detect the data type of a PHP variable

No Comments

The data type of a PHP variable can be detected by using the built-in PHP functiongettype() (PHP 4, PHP 5)

Example:

$var ="This is a sentence"

echo $var; //This will return "string"

The following possible values can be returned:

  • boolean
  • integer
  • double
  • string
  • array
  • object
  • resource
  • NULL
  • unknown type

Image Credits: Photo by Isis França on Unsplash.

Last Updated On March 22, 2018

Related Articles

No results found

Leave a Reply

avatar
  Subscribe  
Notify of
Menu
Copy link