PHP settype() Funkcja
❮ Dokumentacja obsługi zmiennych w PHP
Przykład
Konwertuj zmienne na określone typy:
<?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)
?>
Definicja i użycie
Funkcja settype() konwertuje zmienną na określony typ.
Składnia
settype(variable, type);
Wartości parametrów
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 |
Szczegóły techniczne
Wartość zwrotu: | TRUE w przypadku sukcesu, FALSE w przypadku porażki |
---|---|
Typ zwrotu: | Boole'a |
Wersja PHP: | 4.0+ |
❮ Dokumentacja obsługi zmiennych w PHP