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条)

报告相同问题?

悬赏问题

  • ¥20 谁能帮我挨个解读这个php语言编的代码什么意思?
  • ¥15 win10权限管理,限制普通用户使用删除功能
  • ¥15 minnio内存占用过大,内存没被回收(Windows环境)
  • ¥65 抖音咸鱼付款链接转码支付宝
  • ¥15 ubuntu22.04上安装ursim-3.15.8.106339遇到的问题
  • ¥15 blast算法(相关搜索:数据库)
  • ¥15 请问有人会紧聚焦相关的matlab知识嘛?
  • ¥15 网络通信安全解决方案
  • ¥50 yalmip+Gurobi
  • ¥20 win10修改放大文本以及缩放与布局后蓝屏无法正常进入桌面