PHP settype()関数
例
変数を特定のタイプに変換します。
<?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)
?>
定義と使用法
settype()関数は、変数を特定の型に変換します。
構文
settype(variable, type);
パラメータ値
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 |
技術的な詳細
戻り値: | 成功した場合はTRUE、失敗した場合はFALSE |
---|---|
返品タイプ: | ブール値 |
PHPバージョン: | 4.0以降 |
❮PHP変数処理リファレンス