dismiss Step into the future! Click here to switch to the beta php.net site
downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | conferences | my php.net

search for in the

com_isenum> <com_get
[edit] Last updated: Fri, 04 Oct 2013

view this page in

com_invoke

(PHP 4)

com_invokeCalls a COM component's method [deprecated]

Description

mixed com_invoke ( resource $com_object , string $function_name [, mixed $function_parameters ] )

com_invoke() invokes the method named function_name of the COM component referenced by com_object. com_invoke() returns FALSE on error, returns the function_name's return value on success. All the extra parameters function_parameters are passed to the method function_name.

Example #1 Don't use com_invoke(), use OO syntax instead

<?php
// do this
$val $obj->method($one$two);
// instead of this:
$val com_invoke($obj'method'$one$two);
?>

Note: This function does not exist in PHP 5; instead, you should use the regular and more natural OO syntax to access properties or call methods.



add a note add a note User Contributed Notes com_invoke - [1 notes]
up
0
tomer at parity-bit dot com
8 years ago
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

 
show source | credits | sitemap | contact | advertising | mirror sites