PHP settype() Functie
❮ Referentie voor PHP Variable Handling
Voorbeeld
Converteer variabelen naar specifieke 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)
?>
Definitie en gebruik
De functie settype() converteert een variabele naar een specifiek type.
Syntaxis
settype(variable, type);
Parameterwaarden
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
Winstwaarde: | WAAR bij succes, ONWAAR bij mislukking |
---|---|
Retourtype: | Booleaans |
PHP-versie: | 4.0+ |
❮ Referentie voor PHP Variable Handling