Anonymous function in array

后端 未结 1 629
北荒
北荒 2021-01-20 05:19

I have declared

$func = array(
    \'a\' => array(
        \'b\' => function() {
            echo \"hello\";
        }
    )
);

I try

相关标签:
1条回答
  • 2021-01-20 05:23

    What you did works. Try this:

    <?php
    $func = array(
        'a' => array(
            'b' => function() {
                echo "hello";
            }
        )
    );
    $call = $func['a']['b'];
    $call();
    

    See also here.

    0 讨论(0)
提交回复
热议问题