English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
gettype() La funzione viene utilizzata per ottenere il tipo della variabile.
Attenzione: Non utilizzare gettype() Per testare un tipo, poiché la stringa restituita potrebbe dover cambiare in futuro. Inoltre, a causa della comparazione di stringhe, la sua esecuzione è anche più lenta. Usa le funzioni is_* invece.
Requisiti di versione: PHP 4, PHP 5, PHP 7
string gettype ( mixed $var )
Spiegazione dei parametri:
Restituisce una stringa, possibili valori:
<?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()); ?>
Il risultato di output è:
intero booleano stringa NULL array oggetto