Funzione PHP settype()
❮ Riferimento alla gestione delle variabili PHP
Esempio
Converti le variabili in tipi specifici:
<?php
$a = "32"; // string
settype($a, "integer"); // $a is now integer
$b = 32;
// integer
settype($b, "string"); // $b is now string
$c = true; //
boolean
settype($c, "integer"); // $c is now integer (1)
?>
Definizione e utilizzo
La funzione settype() converte una variabile in un tipo specifico.
Sintassi
settype(variable, type);
Valori dei parametri
Parameter | Description |
---|---|
variable | Required. Specifies the variable to convert |
type | Required. Specifies the type to convert variable to. The possible types are: boolean, bool, integer, int, float, double, string, array, object, null |
Dettagli tecnici
Valore di ritorno: | VERO in caso di successo, FALSO in caso di fallimento |
---|---|
Tipo di reso: | booleano |
Versione PHP: | 4.0+ |
❮ Riferimento alla gestione delle variabili PHP