PHP syntax for dereferencing function result

后端 未结 22 864
不知归路
不知归路 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条回答
  •  长情又很酷
    2020-11-22 02:51

    Short Answer:

    Yes. It is possible to operate on the return value of a function in PHP, so long as the function result and your particular version of PHP support it.

    Referencing example2:

    //  can php say "homer"?      
    //  print zoobar()->fname;     //  homer <-- yup
    

    Cases:

    • The function result is an array and your PHP version is recent enough
    • The function result is an object and the object member you want is reachable

提交回复
热议问题