从类方法调用返回的数组值 - 是否可能? - 这是正常的做法吗? PHP

时间:2013-09-06 07:51:45

标签: php arrays oop methods return

是否可以直接调用方法数组返回的值?
例如

<?php
class test
{
    public function echo_test()
    {
        $return_value["a1"] = "a1a1";
        $return_value["b1"] = "b1b1";
        return $return_value;
    }
}

$newObj = new test();
echo $newObj->echo_test()['a1'];  //<----- this does not seem to work
echo $newObj->echo_test()->a1; //<--------- this does not seem to work as well
echo $newObj['a1']->echo_test(); //<--------- this also do not work

?>

0 个答案:

没有答案