Função PHP settype()
❮ Referência de Manipulação de Variáveis PHP
Exemplo
Converta variáveis para 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)
?>
Definição e uso
A função settype() converte uma variável para um tipo específico.
Sintaxe
settype(variable, type);
Valores de parâmetro
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 |
Detalhes técnicos
Valor de retorno: | TRUE em caso de sucesso, FALSE em caso de falha |
---|---|
Tipo de retorno: | boleano |
Versão do PHP: | 4.0+ |
❮ Referência de Manipulação de Variáveis PHP