PHP -settype()- Funktion
❮ Referenz zur Behandlung von PHP-Variablen
Beispiel
Konvertieren Sie Variablen in bestimmte Typen:
<?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)
?>
Definition und Verwendung
Die Funktion settype() wandelt eine Variable in einen bestimmten Typ um.
Syntax
settype(variable, type);
Parameterwerte
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 |
Technische Details
Rückgabewert: | TRUE bei Erfolg, FALSE bei Misserfolg |
---|---|
Rückgabetyp: | Boolesch |
PHP-Version: | 4.0+ |
❮ Referenz zur Behandlung von PHP-Variablen