php mysqli_fetch_lengths()函数返回结果集中的字段长度。语法为mysqli_fetch_lengths(result);若成功,则该函数返回一个数字数组,若出错或没有其他的行,则返回 false。

php mysqli_fetch_lengths()函数怎么用?
mysqli_fetch_lengths()函数返回结果集中的字段长度。
语法:
立即学习“PHP免费学习笔记(深入)”;
mysqli_fetch_lengths(result);
参数
result:必需。规定由 mysqli_query()、mysqli_store_result() 或 mysqli_use_result() 返回的结果集标识符。
返回值:若成功,则该函数返回一个数字数组,若出错或没有其他的行,则返回 false。
php mysqli_fetch_lengths()函数 示例
返回结果集中的字段长度:
<?php
// 假定数据库用户名:root,密码:123456,数据库:data
$con=mysqli_connect("localhost","root","123456","data");
if (mysqli_connect_errno($con))
{
echo "连接 MySQL 失败: " . mysqli_connect_error();
}
$sql="SELECT name,url FROM websites ORDER BY alexa";
if ($result=mysqli_query($con,$sql))
{
$row=mysqli_fetch_row($result);
// 显示字段长度
foreach (mysqli_fetch_lengths($result) as $i=>$val)
{
printf("字段 %2d 长度为: %2d",$i+1,$val);
echo "<br>";
}
// 释放结果集
mysqli_free_result($result);
}
mysqli_close($con);
?>以上就是php mysqli_fetch_lengths函数怎么用的详细内容,更多请关注php中文网其它相关文章!
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号