PHP弃用:方法具有相同的名称

rjee0c15  于 2023-05-05  发布在  PHP
关注(0)|答案(2)|浏览(156)

我收到一个错误,说
已弃用:与类同名的方法在未来的PHP版本中将不会成为构造函数;Copyright © 2018 www.cnjs.com. All Rights Reserved.粤ICP备15044866号-1
TSStatus类位于第10行,在底部显示TSStatus

class TSStatus
{
    private $_host;
    private $_queryPort;
    private $_serverDatas;
    private $_channelDatas;
    private $_userDatas;
    private $_serverGroupFlags;
    private $_channelGroupFlags;
    private $_login;
    private $_password;
    private $_cacheFile;
    private $_cacheTime;
    private $_channelList;
    private $_useCommand;
    private $_javascriptName;
    private $_socket;

    public $imagePath;
    public $showNicknameBox;
    public $timeout;
    public $hideEmptyChannels;
    public $hideParentChannels;

    public function TSStatus($host, $queryPort)

    ...
}
eni9jsuy

eni9jsuy1#

正如错误中提到的,the official manual和注解:
替换

public function TSStatus($host, $queryPort)

public function __construct($host, $queryPort)
5t7ly7z5

5t7ly7z52#

我得到了警告,关于这个问题,现在它开始工作。一开始是:

function Smarty()
{
  $this->assign('SCRIPT_NAME', isset($_SERVER['SCRIPT_NAME']) ? $_SERVER['SCRIPT_NAME']
                : @$GLOBALS['HTTP_SERVER_VARS']['SCRIPT_NAME']);

但我这样做了:

function _construct()
    {
      $this->assign('SCRIPT_NAME', isset($_SERVER['SCRIPT_NAME']) ? $_SERVER['SCRIPT_NAME']
                    : @$GLOBALS['HTTP_SERVER_VARS']['SCRIPT_NAME']);

现在我已经停止收到警告,脚本运行良好。

相关问题