PHP错误uasort()

时间:2016-06-22 11:07:00

标签: php warnings

我想安装wordpress主题,但我拥有的版本是5.2.17所以我必须重写代码:

// Shortcodes list
//------------------------------------------------------------------
$FIRE_DEPARTMENT_GLOBALS['shortcodes'] = array();

// Add shortcodes
do_action('fire_department_action_shortcodes_list');

// Sort shortcodes list
uasort($FIRE_DEPARTMENT_GLOBALS['shortcodes'], function($a, $b) {
    return strcmp($a['title'], $b['title']);
});

// Shortcodes list
//------------------------------------------------------------------
$FIRE_DEPARTMENT_GLOBALS['shortcodes'] = array();

// Add shortcodes
do_action('fire_department_action_shortcodes_list');

$tmp = fire_department_storage_get('shortcodes');
function strcmp_fun(){
    strcmp($a['title'], $b['title']);
}
uasort($tmp, 'strcmp_fun');
fire_department_storage_set('shortcodes', $tmp);

但我在wordpress中有PHP警告'的debug.log:

  

PHP警告:uasort():参数应该是/(..)/public_html/osp/wp-content/themes/fire-department/fw/core/core.shortcodes/shortcodes_settings.php上的一个数组173

上面的代码有什么问题?

1 个答案:

答案 0 :(得分:0)

没关系?错误消失了

//$tmp = fire_department_storage_get('shortcodes');
            function strcmp_fun($a, $b){
                return strcmp($a['title'], $b['title']);
            }
            uasort($FIRE_DEPARTMENT_GLOBALS['shortcodes'], 'strcmp_fun');
            //fire_department_storage_set('shortcodes', $tmp);