小编Hen*_*wan的帖子

Php7.1致命错误:字符串不支持[]运算符

我构建了一个功能主题选项wordpress.

但是我现在收到以下错误,我做错了什么?

  if(isset($thm_options['custom_font1_eot']))
    $w_custom_font1_src[] = "url('{$thm_options['custom_font1_eot']['url']}?#iefix') format('embedded-opentype')";

  if(isset($thm_options['custom_font1_woff']))   
    $w_custom_font1_src[] = "url('{$thm_options['custom_font1_woff']['url']}') format('woff')";

  if(isset($thm_options['custom_font1_ttf']))
    $w_custom_font1_src[] = "url('{$thm_options['custom_font1_ttf']['url']}') format('truetype')";
Run Code Online (Sandbox Code Playgroud)

致命错误:[]运算符不支持字符串

我错过了什么代码?

php wordpress

1
推荐指数
1
解决办法
1万
查看次数

PHP较小错误,无法在php72上运行的参数太少

我需要帮助解决我的php脚本在php7.2上无法正常工作的小问题,以下代码在php7.0上有效,但在php7.1或7.2上无效:(

调试时显示错误:

    ArgumentCountError: Too few arguments to function smarty_function_gravatar(), 1 passed and exactly 2 expected in public_html/includes/hooks/custom-function.php: Line 91


Stack trace:
    #0 /public_html/includes/hookfunctions.php(0): smarty_function_gravatar(Array)
    #1 /public_html/includes/clientareafunctions.php(0): run_hook('ClientAreaPage', Array)
    #2 /public_html/login.php(0): outputClientArea('login', false, Array)
    #3 /public_html/member/viewticket.php(0): unknown()
    #4 {main}
Run Code Online (Sandbox Code Playgroud)

我在第91行的原始代码:

 function smarty_function_gravatar($params, &$smarty) {
    $email = (isset($params['email']) ? trim(strtolower($params['email'])) : '');
    $rating = (isset($params['rating']) ? $params['rating'] : 'R');
    $url = "https://www.gravatar.com/avatar/".md5($email) . "?r=".$rating;

    if(isset($params['default']))
        $url .= "&d=".urlencode($params['default']);
    if(isset($params['size']))
        $url .= "&s=".$params['size'];

    if(isset($params['assign'])) {
        $smarty->assign($params['assign'], $url);
        return;
    }
    return $url;
 }
Run Code Online (Sandbox Code Playgroud)

在模板.tpl上 …

php smarty whmcs php-7.1 php-7.2

0
推荐指数
1
解决办法
1573
查看次数

标签 统计

php ×2

php-7.1 ×1

php-7.2 ×1

smarty ×1

whmcs ×1

wordpress ×1