我已经在我的 Windows 中编写了这个 PHP 并且工作正常,但在 linux 上它失去了值(value)。
$stmt = mysqli_prepare($con,"SELECT name from `table` where ID=?");
mysqli_stmt_bind_param($stmt,"i",$id);
mysqli_stmt_execute($stmt);
mysqli_stmt_bind_result($stmt, $name);
mysqli_stmt_fetch($stmt);
mysqli_stmt_close($stmt);
if (is_null($name))
echo 'Empty';
在 Linux 上它总是显示为空,但是如果我将代码更改为
...
mysqli_stmt_fetch($stmt);
if (is_null($name))
echo 'Empty';
mysqli_stmt_close($stmt);
然后它不显示EMPTY
我将 $id 与表中存在的值一起使用。
测试于
PHP 5.2 Linux
我在 XP 上使用 PHP 5.3.3
最佳答案
这听起来像是 PHP 处理其内存的另一种方式。这很像在 C++ 中使用悬挂指针。
PHP 手册内容如下:
Closes a prepared statement. mysqli_stmt_close() also deallocates the statement handle. If the current statement has pending or unread results, this function cancels them so that the next query can be executed.
在检索到所有结果(或将值转移到不同的变量)后,您应该始终调用“mysqli_stmt_close()”。
听起来 Linux 在释放内存时正在覆盖内存位置,而 Windows 会保留旧值直到需要内存。
关于php - linux 在 mysqli_stmt_close 后失去值(value),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6913882/