Funkce PHP settype().
❮ Reference manipulace s proměnnými PHP
Příklad
Převést proměnné na konkrétní 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)
?>
Definice a použití
Funkce settype() převede proměnnou na konkrétní typ.
Syntax
settype(variable, type);
Hodnoty parametrů
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 |
Technické údaje
Návratová hodnota: | PRAVDA při úspěchu, NEPRAVDA při neúspěchu |
---|---|
Typ vrácení: | Boolean |
Verze PHP: | 4,0+ |
❮ Reference manipulace s proměnnými PHP