Home > Article > Backend Development > How to use php mysqli_free_result function
php The mysqli_free_result function is used to release the result memory. Its syntax is mysqli_free_result(result). The parameter result is required and there is no return value.
php How to use the mysqli_free_result function?
Definition and usage
mysqli_free_result() function releases the result memory.
Syntax
mysqli_free_result(result);
Parameters
result Required. Specifies the result set identifier returned by mysqli_query(), mysqli_store_result(), or mysqli_use_result().
Return value: No return value.
PHP version: 5
Get rows from the result set and then release the result memory:
<?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); ?>
The above is the detailed content of How to use php mysqli_free_result function. For more information, please follow other related articles on the PHP Chinese website!