dongzhi9906 2012-02-17 12:11
浏览 51
已采纳

我的数组以什么方式索引'非法字符串偏移'?

When "future-proofing" code by testing it on PHP 5.4, I get a warning I don't understand.

function __clone() {
  $this->changed = TRUE;
  foreach ($this->conditions as $key => $condition) {
    if (
    $condition['field']
    instanceOf QueryConditionInterface) {
      $this->conditions[$key]['field'] = clone($condition['field']);
    }
  }
}

I broke out $condition['field'] into its own row to reduce the amount of code to focus on. About that specific line, PHP has this to say

Warning: Illegal string offset 'field' in DatabaseCondition->__clone()

And I just can't see how 'field', is an illegal string offset. I'm guessing that I'm just missing something obvious, but if the community can't find a problem, I'll file a bug report.

I interpret the warning as "Under no circumstances is 'field' a valid key". This error would have made sense if I had tried to us for example an array as a key.

  • 写回答

2条回答 默认 最新

  • doufangpian5545 2012-02-17 21:17
    关注

    The warning looks like its saying that $condition is a string. Without any knowledge of the code I don't whether that makes any sense.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置