COM 函数
在线手册:中文 英文
PHP手册

com_invoke

(PHP 4)

com_invoke 调用 COM 组件的方法。

描述

mixed com_invoke ( resource $com_object , string $function_name [, mixed $ function parameters, ... ] )

com_invoke() 调用由 com_object 所引用的对象的方法。出错返回 FALSE,成功则返回 function_name 的返回值。


COM 函数
在线手册:中文 英文
PHP手册
PHP手册 - N: 调用 COM 组件的方法。

用户评论:

tomer at parity-bit dot com (01-Feb-2005 08:21)

Note that if you want to use a string to specify the method to call (e.g. a drop-down list to decide what to do to a server process) you can do this in three ways.

The first is to use this function, as in <?php com_invoke($obj, $_GET['func']); ?>
That's bad.

The second is to use eval(), as in <?php eval("\$obj->{$_GET['func']}();"); ?>
That's very very very *very* bad.

The third is to use call_user_func(), as in <?php call_user_func(array($obj, $_GET['func'])); ?>
That's very good.

Remember to validate the user input against a list of allowed methods if a non-admin is at the console.

http://php.net/manual/en/function.call-user-func.php