dtwzwmv87399 2013-04-28 04:48
浏览 10
已采纳

如何通过引用错误解决此问题?

This is part of a drupal module and I am getting this error:

Strict warning: Only variables should be passed by reference in customheaderimage_get_last_argument()

My code is

function customheaderimage_get_last_argument() {
  return customheaderimage_dashtoslash(array_pop(explode('/', $_GET['q'])));
}

q contains a value like "admin/configure/customheaderimage/edit/node--2" the dashtoslash changes the -- to a slash with str_replace. so all of those chained functions return something like 'node/2' and it currently does and works. Just throws this warning

How do I resolve this warning message it does this in a few places?

  • 写回答

1条回答 默认 最新

  • duanlipeng4136 2013-04-28 05:01
    关注

    array_pop() takes an argument by reference:

    mixed array_pop ( array &$array )

    It needs the reference because it modifies the array passed in as the argument. You're passing the result of a function and not a variable, so the reference doesn't make sense. In other words, you need to pass a variable as the argument.

    function customheaderimage_get_last_argument() {
      $arr = explode('/', $_GET['q']);
      return customheaderimage_dashtoslash(array_pop($arr));
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用
  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?