PHP syntax for dereferencing function result

后端 未结 22 899
不知归路
不知归路 2020-11-22 02:14

Background

In every other programming language I use on a regular basis, it is simple to operate on the return value of a function without declaring

22条回答
  •  闹比i
    闹比i (楼主)
    2020-11-22 02:42

    PHP can not access array results from a function. Some people call this an issue, some just accept this as how the language is designed. So PHP makes you create unessential variables just to extract the data you need.

    So you need to do.

    $var = foobar();
    print($var[0]);
    

提交回复
热议问题