settype
(PHP 4, PHP 5)
settype — 변수형을 설정합니다.
설명
bool settype
( mixed $var
, string $type
)
var 의 변수형을 type 로 설정합니다.
사용할 수 있는 type 의 값은:
- "boolean" (혹은, PHP 4.2.0부터, "bool")
- "integer" (혹은, PHP 4.2.0부터, "int")
- "float" (PHP 4.2.0부터만 가능하고, 이전의 버전은 배제된 표현 "double"을 사용합니다)
- "string"
- "array"
- "object"
- "null" (PHP 4.2.0부터)
성공할 경우 TRUE를, 실패할 경우 FALSE를 반환합니다.
Example#1 settype() 예제
<?php
$foo = "5bar"; // string
$bar = true; // boolean
settype($foo, "integer"); // $foo는 5 (integer)
settype($bar, "string"); // $bar는 "1" (string)
?>