PHP settype()ฟังก์ชั่น
❮ ข้อมูลอ้างอิงการจัดการตัวแปร PHP
ตัวอย่าง
แปลงตัวแปรเป็นประเภทเฉพาะ:
<?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 |
รายละเอียดทางเทคนิค
คืนมูลค่า: | จริงกับความสำเร็จ เท็จเมื่อล้มเหลว |
---|---|
ประเภทการคืนสินค้า: | บูลีน |
รุ่น PHP: | 4.0+ |
❮ ข้อมูลอ้างอิงการจัดการตัวแปร PHP