【问题标题】:Warning: Illegal string offset 'title' Error警告:非法字符串偏移“标题”错误
【发布时间】:2014-12-23 19:20:05
【问题描述】:

这是它所引用的行:

$html = '<div class="devider"><a id="back-top" class="top" href="#top">'.$atts["title"].'</a></div><hr />';

使用 wordpress 4.1 和 PHP 5.5

刚刚将我的网站移动到一个新的方式,这个错误出现在几个页面上:

警告:第 105 行 /mydomain/wp-content/themes/mytheme/include/short_code.php 中的非法字符串偏移“标题”

【问题讨论】:

  • var_dump($atts); 里面有什么?请告诉我们

标签: php string wordpress


【解决方案1】:

我收到了针对 members.php 的警告

我的代码在很多地方都有这个:

if($a['search'] !== false and $a['search'] !== 'false') {
            $r .= $this->search();
        }
I had to change it to this to remove the warning:
if(isset($a['search']) !== false and isset($a['search']) !== 'false') {
            $r .= $this->search();
        }

但是后来我丢失了我的搜索框,所以在表达式的第一部分中我没有不等于,而是将其更改为等于(去掉了!):

if(isset($a['search']) == false and isset($a['search']) !== 'false') {
$r .= $this->search();
}
I had to also change a line that looked like:
$this->list = $a['list'];

到:

$this->list = isset($a['list']);

希望这会有所帮助..

【讨论】:

  • 感谢您的评论 Sandesh,我不确定这一切意味着什么,但我确实意识到了一些事情。每次我使用这个水平线简码“[cs_divider]”时,错误文本就会出现多少次。例如,页面有 5 行,而错误文本出现了 5 次。有什么建议吗?
猜你喜欢
  • 1970-01-01
  • 2021-09-30
  • 2013-09-13
  • 2013-04-11
  • 2012-04-09
  • 2019-07-28
  • 1970-01-01
相关资源
最近更新 更多