加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

如何修复PHP中的警告非法字符串偏移量

发布时间:2020-12-13 13:22:03 所属栏目:PHP教程 来源:网络整理
导读:我有这个 PHP代码块给了我错误: Warning : Illegal string offset ‘iso_format_recent_works’ in C:xampphtdocsMantawp-contentthemesmantafunctions.php on line 1328 这是警告与之相关的代码: if(1 == $manta_option['iso_format_recent_works'
我有这个 PHP代码块给了我错误:

Warning: Illegal string offset ‘iso_format_recent_works’ in
C:xampphtdocsMantawp-contentthemesmantafunctions.php on
line 1328

这是警告与之相关的代码:

if(1 == $manta_option['iso_format_recent_works']){
    $theme_img = 'recent_works_thumbnail';
} else {
    $theme_img = 'recent_works_iso_thumbnail';
}

当我做一个var_dump($manta_option);我收到以下结果:

[“iso_format_recent_works”]=> string(1) “1”

我已经尝试将$manta_option [‘iso_format_recent_works’]转换为int但仍然遇到同样的问题.

任何帮助将不胜感激!

魔术词是:isset

验证条目:

if(isset($manta_option['iso_format_recent_works']) && $manta_option['iso_format_recent_works'] == 1){
    $theme_img = 'recent_works_thumbnail';
} else {
    $theme_img = 'recent_works_iso_thumbnail';
}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读