Función PHP settype()
❮ Referencia de manejo de variables de PHP
Ejemplo
Convierta variables a tipos específicos:
<?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)
?>
Definición y uso
La función settype() convierte una variable a un tipo específico.
Sintaxis
settype(variable, type);
Valores paramétricos
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 |
Detalles técnicos
Valor devuelto: | VERDADERO en caso de éxito, FALSO en caso de fracaso |
---|---|
Tipo de devolución: | booleano |
Versión PHP: | 4.0+ |
❮ Referencia de manejo de variables de PHP