$string = "my_method";
$a=explode("_",$string);
foreach($a as $string)
{
$method=$method.ucwords($string);
}
echo $method."()";
function MyMethod(){
return "in my method";
}
我得到了代码'my_method',我必须从中创建'MyMethod()'方法并显示方法的内容
答案 0 :(得分:1)
尝试使用此代码:
<?php
$string = "my_method";
$a = explode("_", $string);
$method = '';
foreach($a as $string)
{
$method.= ucwords($string);
}
echo $method();
function MyMethod(){
return "in my method";
}