怎样用c++实现php的call_user_func
解决方案 »
- vc编写报错!急
- 考研的心萌芽了,散分 深圳大学计算机专业
- 关于simplegraph?
- 菜鸟求助:如何将一个ACCSESS表单添加到单文档工程文件中
- 提一个关于无模式对话框的初级问题,求教~!
- 一个简单的API问题,分数不要白不要!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- 特别奇怪~
- win32应用程序能否调用C#中的wpf库
- 请问directx sdk 例子程序中 __out 无法编译通过的问题?
- 弹出菜单??急急!!
- BCGControlBar中VisualManager是怎样获得MainFrame的消息的?
- 求VC 用ASCII加密解密的函数,下面是C#的,我想改成VC的,谢谢。
能在详细一点说明么?
(PHP 3>= 3.0.3, PHP 4 , PHP 5)call_user_func -- Call a user function given by the first parameter
Description
mixed call_user_func ( callback function [, mixed parameter [, mixed ...]])
Call a user defined function given by the function parameter. Take the following: <?php
function barber($type)
{
echo "You wanted a $type haircut, no problem";
}
call_user_func('barber', "mushroom");
call_user_func('barber', "shave");
?> Object methods may also be invoked statically using this function by passing array($objectname, $methodname) to the function parameter. <?php
class myclass {
function say_hello()
{
echo "Hello!\n";
}
}$classname = "myclass";call_user_func(array($classname, 'say_hello'));
?>
就是一个通过字符串执行与这个字符串同名的函数的函数!
在数据库中取出来的只是字符串,不能得到对应函数的指针只需要传一个与函数名相同的字符串就能call这个函数了。有点像dll中的 GetProcAddress难道只能把所有有可能调用的函数都封装在dll里面?
当然,导出函数除外,在导出表中有函数名的记录。你可以把你要调用的函数都弄成导出函数,然后在程序里面用GetProcAddress
call_user_func那样
<?php
function barber($type)
{
echo "You wanted a $type haircut, no problem";
}
call_user_func('barber', "mushroom");
call_user_func('barber', "shave");
?>
这里的结果是:
You wanted a mushroom haircut, no problem
You wanted a shave haircut, no problem