PHP 执行与变量值相同的方法

mixed call_user_func ( callback $function [, mixed $parameter [, mixed $...]] )

mixed call_user_func_array ( callback $function, array $param_arr )

<?php
function barber($type)
{
echo "You wanted a $type haircut, no problem";
}
call_user_func('barber', "mushroom");
call_user_func('barber', "shave");
?>

-----------------或者你可以这样

<?php

function fuck()
{
echo 'fuck';
}

$a = 'fuck';
$a();
--------------------------全面的写法
<?php

class test extends  testBase{

    function name()
    {
        echo 'name namenamenamename11111111 ';
    }

    function pass()
    {
        echo 'passpasspasspasspasspass22222222222 ';
    }

}

class testBase{

    function __construct()
    {
        $test_func=$_GET['st'];
        $this->$test_func();
    }
}

new test();
原文地址:https://www.cnblogs.com/dengcw/p/5640262.html