Access array returned by a function in php

前端 未结 5 595
抹茶落季
抹茶落季 2020-11-22 12:43

I\'m using a template engine that inserts code in my site where I want it.

I wrote a function to test for something which is quite easy:

myfunction()         


        
5条回答
  •  我在风中等你
    2020-11-22 12:56

    $this->data is always accessible, if it is protected. $object->data is not accessible from everywhere, so if you're returning $this in your code, and it is evaluated as such, it should be ok.

    Btw, there is a bug in your code: The quotes need to be escaped.

    myfunction() { return '($this->data[\'a\'][\'b\'] ? true : false)'; }
    

提交回复
热议问题