运营狗 - 失效 https://blog.seo135.com/tag/%E5%A4%B1%E6%95%88/ 织梦DedeCMS关键词自动内链php5.5以上失效问题解决方法 https://blog.seo135.com/465.html 2019-05-19T10:51:00+08:00 当PHP版本高于5.5时,织梦DedeCMS无法使用关键词內链,下面是此问题的解决方法。打开 /include/arc.archives.class.php 找到$body = @preg_replace_callback("#(^|>)([^<]+)(?=<|$)#sU", "_highlight('\\2', \$karr, \$kaarr, '\\1')", $body);改成global $cfg_replace_num; if($cfg_replace_num > 0) { $query = "SELECT char_length(keyword) AS num,aid,keyword,rpurl,rank FROM #@__keywords WHERE rpurl<>'' ORDER BY num DESC"; $this->dsql->SetQuery($query); $this->dsql->Execute(); while($row = $this->dsql->GetArray()) { $key = trim($row['keyword']); $key_url=trim($row['rpurl']); $body = str_replace_limit($key, "<a href='$key_url' target='_blank'><u>$key</u></a>", $body, $cfg_replace_num); } } else { $query = "SELECT char_length(keyword) AS num,aid,keyword,rpurl,rank FROM #@__keywords WHERE rpurl<>'' ORDER BY num DESC"; $this->dsql->SetQuery($query); $this->dsql->Execute(); while($row = $this->dsql->GetArray()) { $key = trim($row['keyword']); $key_url=trim($row['rpurl']); $body = str_replace($key, "<a href='$key_url' target='_blank'><u>$key</u></a>", $body); } }继续找到//高亮专用在它上面加入//指定替换次数功能 function str_replace_limit($search, $replace, $subject, $limit) { if(is_array($search)) { foreach($search as $k=>$v) { $search[$k] = '#(?<!>)(?!<)'. preg_quote($search[$k], '#'). '#'; } } else { $search = '#(?<!>)(?!<)'. preg_quote($search, '#'). '#'; } return preg_replace($search, $replace, $subject, $limit); }完成