PHP error: quot;Cannot pass parameter 2 by referencequot;(PHP 错误:“无法通过引用传递参数 2)
问题描述
我只是需要帮助解决这个我不太明白的 PHP 错误:
I just need help on this PHP error which I do not quite understand:
致命错误:无法在第 13 行的/web/stud/openup/inactivatesession.php 中通过引用传递参数 2
Fatal error: Cannot pass parameter 2 by reference in /web/stud/openup/inactivatesession.php on line 13
<?php
error_reporting(E_ALL);
include('connect.php');
$createDate = mktime(0,0,0,09,05,date("Y"));
$selectedDate = date('d-m-Y', ($createDate));
$sql = "UPDATE Session SET Active = ? WHERE DATE_FORMAT(SessionDate,'%Y-%m-%d' ) <= ?";
$update = $mysqli->prepare($sql);
$update->bind_param("is", 0, $selectedDate); //LINE 13
$update->execute();
?>
这个错误是什么意思?如何修复此错误?
What does this error mean? How can this error be fixed?
推荐答案
该错误意味着第二个参数应该是对变量的引用.
The error means that the 2nd argument is expected to be a reference to a variable.
由于您处理的不是变量,而是值 0 的整数,因此会产生上述错误.
Since you are not handing a variable but an integer of value 0, it generates said error.
要避免这种情况,请执行以下操作:
To circumvent this do:
$a = 0;
$update->bind_param("is", $a, $selectedDate); //LINE 13
如果您想了解正在发生的事情,而不是仅仅修复您的致命错误
,请阅读以下内容:http://php.net/manual/en/language.references.pass.php
In case you want to understand what is happening, as opposed to just fixing your Fatal error
, read this: http://php.net/manual/en/language.references.pass.php
这篇关于PHP 错误:“无法通过引用传递参数 2"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:PHP 错误:“无法通过引用传递参数 2"


- 正确分离 PHP 中的逻辑/样式 2021-01-01
- PHP Count 布尔数组中真值的数量 2021-01-01
- 从 PHP 中的输入表单获取日期 2022-01-01
- Mod使用GET变量将子域重写为PHP 2021-01-01
- Laravel 仓库 2022-01-01
- 没有作曲家的 PSR4 自动加载 2022-01-01
- 带有通配符的 Laravel 验证器 2021-01-01
- SoapClient 设置自定义 HTTP Header 2021-01-01
- Oracle 即时客户端 DYLD_LIBRARY_PATH 错误 2022-01-01
- 如何定位 php.ini 文件 (xampp) 2022-01-01