在php 8.2中已弃用可选参数$mode在required参数之前声明

gojuced7  于 2023-06-28  发布在  PHP
关注(0)|答案(1)|浏览(253)

我在更新到php 8.2后得到以下错误:
在php 8.2中已弃用可选参数$mode在required参数$name之前声明被隐式地视为required参数。

/* 
 * function getHEAD has 3 modes:
 *  META = get META tags for current content level
 *  override = override for current content level (used for override maintenance)
 *  generated = exclude override for current content level (for override maintenance) 
 */
    function getHEAD($mode='META', $name) { //deprecated in php 8.2
        global $db, $prefix, $dhTitle, $dhDesc, $dhKeys, $seocatid, $seosubcatid, $sitename, $slogan;
        $this->setModuleName($name);
        $dhTitle = $dhDesc = $dhKeys = '';
        $contentTDK = $catTDK = array();
        $id = intval($this->getContentID());
        $catidfld = $this->cat_id;
        $seocatid = intval($this->getCatID());
        $subcatidfld = $this->subcat_id;
        $seosubcatid = intval($this->getSubCatID());
        if ($seocatid ==0 and $seosubcatid > 0 and $this->dh_bLinkCatSubcat) $seocatid = $this->getCatIDfromSubcat();
        $level = $this->getContentLevel();

我试着去做

function getHEAD($mode='META=null, $name) {//NO LUCKY
qlfbtfca

qlfbtfca1#

在PHP的新版本中,你应该把函数的可选参数放在末尾,所以在你的情况下,你的代码应该是这样的:

function getHEAD($name , $mode='META') 
{
// the rest

PS:从PHP 8.0开始,你可以使用命名参数的函数...

相关问题