更新php版本后出现错误


Errors after update php version

在更新php版本后,我遇到了很多错误,网站无法工作。

[Wed Sep 10 21:47:14.094755 2014] [:error] [pid 21347] [client 5.28.155.234:59471] PHP Notice:  Undefined variable: text in /home/**/inc/function.php on line 81
[Wed Sep 10 21:47:14.094785 2014] [:error] [pid 21347] [client 5.28.155.234:59471] PHP Notice:  Undefined variable: text in /home/**/inc/function.php on line 81
[Wed Sep 10 21:47:14.094794 2014] [:error] [pid 21347] [client 5.28.155.234:59471] PHP Notice:  Undefined offset: 3 in /home/**/inc/function.php on line 81
[Wed Sep 10 21:47:14.094814 2014] [:error] [pid 21347] [client 5.28.155.234:59471] PHP Notice:  Undefined variable: text in /home/**/inc/function.php on line 81
[Wed Sep 10 21:47:14.094822 2014] [:error] [pid 21347] [client 5.28.155.234:59471] PHP Notice:  Undefined offset: 3 in /home/**/inc/function.php on line 81
[Wed Sep 10 21:47:14.094842 2014] [:error] [pid 21347] [client 5.28.155.234:59471] PHP Notice:  Undefined variable: text in /home/**/inc/function.php on line 81
[Wed Sep 10 21:47:14.094849 2014] [:error] [pid 21347] [client 5.28.155.234:59471] PHP Notice:  Undefined offset: 3 in /home/**/inc/function.php on line 81
[Wed Sep 10 21:47:14.094869 2014] [:error] [pid 21347] [client 5.28.155.234:59471] PHP Notice:  Undefined variable: text in /home/**/inc/function.php on line 81
[Wed Sep 10 21:47:14.094876 2014] [:error] [pid 21347] [client 5.28.155.234:59471] PHP Notice:  Undefined offset: 3 in /home/**/inc/function.php on line 81
[Wed Sep 10 21:47:14.094902 2014] [:error] [pid 21347] [client 5.28.155.234:59471] PHP Fatal error:  Call to undefined function session_register() in /home/**/inc/config.php on line 58

代码是:

第81行:

    {
        $text.=$e[$i]." ";
    }

配置文件第58行:

session_register("views");

在您的错误消息中有您所需要的一切:

variable: text in /home/**/inc/function.php on line 81

这意味着之前没有设置有效的CCD_ 1。所以在前面定义变量。

二是session_register()不再受支持。所以更换它。

$_SESSION['views'] = 'test';

您以前也有这样的错误,但您已经禁用了通知。

这个集合不是在if内部吗?

{
    $text.=$e[$i]." ";
}

如果是,并且情况为false,则根本不会设置此变量。例如,您可以通过在脚本开头像$text = '';一样声明该消息来绕过该消息。这可能不是最好的做法,但它会消除这个信息。

未定义的偏移量指的是——如果没有更多的代码,很难确定——没有$e[3]这样的东西。它在for循环中吗?如果是这样的话,可能是因为您使用的是$i <= something而不是$i < something

此外,session_register仅用于<PHP 5.4.0。

你可以这样做,例如

$_SESSION['username'] = $username;

在使用$text.=$e[$i]." ";之前,必须定义$text。例如$text ="";$text0等。