【问题标题】:Error PHP 7.4 Trying to access array offset on value of type bool in错误 PHP 7.4 试图访问 bool 类型值的数组偏移量
【发布时间】:2021-02-05 01:25:31
【问题描述】:

第 25 行

if($respuesta["usuario"] == $_POST["ingUsuario"] && $respuesta["password"]== $encriptar){

【问题讨论】:

标签: php pdo error-handling php-7.4


【解决方案1】:

从 PHP 7.4 开始,当尝试将 null、bool、int、float 或资源类型的值用作数组时,它会生成通知。

https://www.php.net/manual/en/migration74.incompatible.php#migration74.incompatible.core.non-array-access

非数组的数组式访问

尝试使用 null、bool、int、float 或 resource 类型的值作为 数组(例如 $null["key"])现在会生成一个通知。

为避免引起注意,您可以先检查 $respuesta 是否为数组:

if(is_array($respuesta) && $respuesta["usuario"] == $_POST["ingUsuario"] && $respuesta["password"]== $encriptar){

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-04-27
    • 1970-01-01
    • 2020-10-17
    • 1970-01-01
    • 2020-10-03
    相关资源
    最近更新 更多