dongqigu0429 2013-08-04 18:56
浏览 32
已采纳

正确访问数组[重复]

This question already has an answer here:

I've seen people write code like this:

$image_url =  wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), array(300, 300), false, ''); 
$image_url = $image_url[0];

which seems a little ridiculous because you could just attach the [0] to the end of the first term. So I never did it in my local machine, but now when deploying to remote machines (with possibly different versions of php, I always get bugs about unexpected '['. Does php not accept accessing arrays in-place, or was there some change in some version?

</div>
  • 写回答

3条回答 默认 最新

  • douwen7331 2013-08-04 18:58
    关注

    This is allowed since PHP 5.4:

    Function array dereferencing has been added, e.g. foo()[0].

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

报告相同问题?

悬赏问题

  • ¥35 平滑拟合曲线该如何生成
  • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
  • ¥15 名为“Product”的列已属于此 DataTable
  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
  • ¥50 成都蓉城足球俱乐部小程序抢票
  • ¥15 yolov7训练自己的数据集