PHP gettype() Funzione
❮ Riferimento alla gestione delle variabili PHP
Esempio
Restituisce il tipo di diverse variabili:
<?php
$a = 3;
echo gettype($a) . "<br>";
$b = 3.2;
echo
gettype($b) . "<br>";
$c = "Hello";
echo gettype($c) . "<br>";
$d = array();
echo
gettype($d) . "<br>";
$e = array("red", "green", "blue");
echo
gettype($e)
. "<br>";
$f = NULL;
echo gettype($f) . "<br>";
$g = false;
echo gettype($g) . "<br>";
?>
Definizione e utilizzo
La funzione gettype() restituisce il tipo di una variabile.
Sintassi
gettype(variable);
Valori dei parametri
Parameter | Description |
---|---|
variable | Required. Specifies the variable to check |
Dettagli tecnici
Valore di ritorno: | Il tipo come stringa. Può essere uno dei seguenti valori: "boolean", "integer", "double", "string", "array", "object", "resource", "NULL", "unknown type" |
---|---|
Tipo di reso: | Corda |
Versione PHP: | 4.0+ |
Registro delle modifiche PHP: | PHP 7.2: le risorse chiuse vengono ora restituite come "risorsa (chiusa)". In precedenza, il valore restituito era "tipo sconosciuto". |
❮ Riferimento alla gestione delle variabili PHP