该代码在php5.4上工作正常但在php5.3中没有如何修改它以使用php5.3

时间:2018-05-01 22:22:58

标签: php-5.3 php-5.4

我在本地服务器上使用php5.4的joomla网站,它工作正常 但是当我将它上传到实时服务器时,所有网站都在第491行给出错误“意外[”] 在example.php中 当评论该行时它运作良好但我不确定这是否会在某些扩展中出现问题。

第491行给出了该错误

$hash = md5(json_encode([$reftable,$reffield, $refids, $language]));

包含此行的完整功能代码为:

public function getRawFieldTranslations($reftable,$reffield, $refids, $language)
{

    static $cache = array();

    $hash = md5(json_encode([$reftable,$reffield, $refids, $language]));

    if (!isset($cache[$hash])) {
        $db      = JFactory::getDbo();
        $dbQuery = $db->getQuery(true)
            ->select($db->quoteName('value'))
            ->from('#__falang_content fc')
            ->where('fc.reference_id = ' . $db->quote($refids))
            ->where('fc.language_id = ' . (int) $language)
            ->where('fc.published = 1')
            ->where('fc.reference_field = ' . $db->quote($reffield))
            ->where('fc.reference_table = ' . $db->quote($reftable));

        $db->setQuery($dbQuery);
        $result  = $db->loadResult();

        //$cache[$hash] don't like null value
        if (!empty($result)){
           $cache[$hash] = $result;
        } else {
           $cache[$hash] = '';
        }

    }

    return $cache[$hash];
}

所以,热门准确修改此代码以使用php5.3

0 个答案:

没有答案