gpt4 book ai didi

php - 第 2 行第 1 列错误 : Extra content at the end of the document in PHP public function

转载 作者:行者123 更新时间:2023-11-29 18:48:54 26 4
gpt4 key购买 nike

我有功能:

    protected function getFeedCategory($lng) {
$params = $this->dispatcher->getParam('format', null, '/id/1');
$pArr = explode("/", $params);
$limit = 10;
//varDump($pArr);
//varDump($this->dispatcher->getParams());
try {

$categoryId = (isset($pArr[2])) ? (int)$pArr[2] : 1;
$cache_key = 'Frontend_Feed_getFeedCategory_' . $categoryId . '_limit_' . $limit . '_' . $lng;
//$this->_cache->delete($cache_key);
if (($items = $this->_cache->get($cache_key)) == null || $this->cache_renew_data->can_refrash) {
$items = $this->db->fetchAll("SELECT n.date_show, n.title_{$lng} AS title,n.id,n.is_ru,n.is_md,n.is_new,n.thumb_md,n.thumb_ru,
n.thumb_en
FROM news AS n
LEFT JOIN news_categories AS nc ON nc.news_id=n.id
WHERE n.is_{$lng} = 1 AND n.date_show < '" . date(MYSQL_DATE_FORMAT) . "'
AND nc.categories_id = {$categoryId}
ORDER BY n.date_show DESC LIMIT 0," . $limit);
//varDump($items);
if (count($items)) {
$this->_cache->save($cache_key, $items);
}
}


} catch (\Exception $e) {
return $this->getAll($lng, 20);
}

return $items;
}

第 1 列第 2 行返回错误:文档末尾有额外内容,我该如何修复它?

案例“提要类别”:
$items = $this->getFeedCategory($lng);
中断;

此代码获取带有 url 的内容!

最佳答案

public function getFeedCategory($lng) {
$params = $this->dispatcher->getParam('format', null, '/id/1');
$pArr = explode("/", $params);
$limit = 10;

try {
$categoryId = (isset($pArr[2])) ? (int)$pArr[2] : 1;
$cache_key = 'Frontend_Feed_getFeedCategory_' . $categoryId . '_limit_' . $limit . '_' . $lng;

if (($items = $this->_cache->get($cache_key)) == null || $this->cache_renew_data->can_refrash) {
$items = $this->db->fetchAll("SELECT n.date_show, n.title_{$lng} AS title,n.id,n.is_ru,n.is_md,n.is_new,n.thumb_md,n.thumb_ru,
n.thumb_en
FROM news AS n
LEFT JOIN news_categories AS nc ON nc.news_id=n.id
WHERE n.is_{$lng} = 1 AND n.date_show < '" . date(MYSQL_DATE_FORMAT) . "'
AND nc.categories_id = {$categoryId}
ORDER BY n.date_show DESC LIMIT 0," . $limit);

if (count($items)) {
$this->_cache->save($cache_key, $items);
return $items;
}
}
} catch (\Exception $e) {
return $this->getAll($lng, 20);
}
}

关于php - 第 2 行第 1 列错误 : Extra content at the end of the document in PHP public function,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44452339/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com