Easy Tutorial
❮ Func Curl_Multi_Exec Pdo Getavailabledrivers ❯

PHP gettype() Function

PHP Available Functions

The gettype() function is used to get the type of a variable.

Note: Do not use gettype() to test for a certain type, as the returned string may need to change in future versions. Additionally, it is slower due to string comparison. Use is_* functions instead.

Version Requirements: PHP 4, PHP 5, PHP 7

Syntax

string gettype ( mixed $var )

Parameter Description:

Return Value

Returns a string, possible values are:

Example

<?php
echo gettype(102) . PHP_EOL;
echo gettype(true) . PHP_EOL;
echo gettype(' ') . PHP_EOL;
echo gettype(null) . PHP_EOL;
echo gettype(array()) . PHP_EOL;
echo gettype(new stdclass());
?>

Output:

integer
boolean
string
NULL
array
object

PHP Available Functions

❮ Func Curl_Multi_Exec Pdo Getavailabledrivers ❯