dp6319 2012-07-07 12:08
浏览 16
已采纳

PHP函数以变量的值命名

I have a PHP function that I need to create that executes PHP or HTML Code that is stored in a variable. That's one problem. Another problem is the fact that the function will be created multiple times and will need a unique name so I've named it after $title but I'm not sure if this will create the function from the value of $title or if it will create a function called $title or if it just won't work. This is my code:

$title = $_POST['sogo_aso_name'];
$output = $_POST['sogo_aso_output'];

Some Code Here...

function $title ($output)
{
    //Some Code Here to execute $output...
}

So... That's my problem. I'm not sure what will execute the $output cleanly so it can be shown on a page. And I don't know if the function will be named after the value of $title

Thanks for any help!

Ethan Brouwer

  • 写回答

2条回答 默认 最新

  • doubaoguo7469 2012-07-07 12:16
    关注

    You can use call_user_func like this:

    call_user_func($title, $output);
    

    But it's really strange to change name of one function.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 用verilog实现tanh函数和softplus函数
  • ¥15 Hadoop集群部署启动Hadoop时碰到问题
  • ¥15 求京东批量付款能替代天诚
  • ¥15 slaris 系统断电后,重新开机后一直自动重启
  • ¥15 QTableWidget重绘程序崩溃
  • ¥15 谁能帮我看看这拒稿理由啥意思啊阿啊
  • ¥15 关于vue2中methods使用call修改this指向的问题
  • ¥15 idea自动补全键位冲突
  • ¥15 请教一下写代码,代码好难
  • ¥15 iis10中如何阻止别人网站重定向到我的网站