gettype

(PHP 4, PHP 5, PHP 7)

gettypeObtém o tipo da variável

Descrição

gettype ( mixed $var ) : string

Retorna o tipo da variável no PHP var. Para checagem de tipo, utilize as funções is_*.

Parâmetros

var

A variável a ter o tipo verificado.

Valor Retornado

Os possíveis valores retornados pela função são:

Exemplos

Exemplo #1 Exemplo da função gettype()

<?php

$data 
= array(11.NULL, new stdClass'foo');

foreach (
$data as $value) {
    echo 
gettype($value), "\n";
}

?>

O exemplo acima irá imprimir algo similar à:

integer
double
NULL
object
string

Veja Também