PHP mysql_field_type() 函數
定義和用法
mysql_field_type() 函數返回結果集中指定字段的類型。
如果成功,則返回指定字段的類型,如果失敗,則返回 false。
語法
mysql_field_type(data,field_offset)
參數 | 描述 |
---|---|
data | 必需。要使用的數據指針。該數據指針是從 mysql_query() 返回的結果。 |
field_offset | 必需。指示從哪個字段開始返回。0 指示第一個字段。 |
實例
<?php $con = mysql_connect("localhost", "hello", "321"); if (!$con) { die('Could not connect: ' . mysql_error()); } $db_selected = mysql_select_db("test_db",$con); $sql = "SELECT * from Person"; $result = mysql_query($sql,$con); $type = mysql_field_type($result, 0); echo $type; mysql_close($con); ?>
輸出:
string