array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'zh', ), 'this' => array ( 0 => 'function.mysql-num-fields.php', 1 => 'mysql_num_fields', ), 'up' => array ( 0 => 'ref.mysql.php', 1 => 'MySQL 函数', ), 'prev' => array ( 0 => 'function.mysql-list-tables.php', 1 => 'mysql_list_tables', ), 'next' => array ( 0 => 'function.mysql-num-rows.php', 1 => 'mysql_num_rows', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'zh', 'path' => 'reference/mysql/functions/mysql-num-fields.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(PHP 4, PHP 5)
mysql_num_fields — 取得结果中字段的数量
本扩展自 PHP 5.5.0 起已废弃,并在自 PHP 7.0.0 开始被移除。应使用 MySQLi 或 PDO_MySQL 扩展来替换之。参见 MySQL:选择 API 指南来获取更多信息。用以替代本函数的有:
示例 #1 mysql_num_fields() 示例
<?php
$result = mysql_query("SELECT id,email FROM people WHERE id = '42'");
if (!$result) {
echo 'Could not run query: ' . mysql_error();
exit;
}
/* returns 2 because id,email === two fields */
echo mysql_num_fields($result);
?>
注意:
为了向下兼容,可以使用下列已废弃的别名: mysql_numfields()