首頁  >  文章  >  後端開發  >  php mysqli_free_result函數怎麼用

php mysqli_free_result函數怎麼用

藏色散人
藏色散人原創
2019-05-26 14:36:343080瀏覽

php mysqli_free_result函數用於釋放結果內存,其語法為mysqli_free_result(result),參數result是必要的,沒有傳回值。

php mysqli_free_result函數怎麼用

php mysqli_free_result函數怎麼用?

定義和用法

mysqli_free_result() 函數釋放結果記憶體。

語法

mysqli_free_result(result);

參數

#result 必要。規定由 mysqli_query()、mysqli_store_result() 或 mysqli_use_result() 傳回的結果集標識符。

傳回值: 沒有傳回值。

PHP 版本: 5

從結果集中取得行,然後釋放結果記憶體:

<?php 
// 假定数据库用户名:root,密码:123456,数据库:RUNOOB 
$con=mysqli_connect("localhost","root","123456","RUNOOB"); 
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))
{
    // 一行行获取
    while ($row=mysqli_fetch_row($result))
    {
        printf ("%s : %s",$row[0],$row[1]);
        echo "<br>";
    }
    // 释放结果集
    mysqli_free_result($result);
}
 
mysqli_close($con);
?>

以上是php mysqli_free_result函數怎麼用的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn