What is PhpDig?
PhpDig is a PHP MySQL based
Web Spider & Search Engine.



call_user_method — Alternate strategy for calling a method from an object.


mixed call_user_method(method_name, obj[, method_parameter][, . . .]);
string method_name: Method to be called
object obj: Object to which the method belongs
mixed method_parameter (optional): First argument to be passed to the method
mixed . . . (optional): Additional arguments to be passed to the method


Return value of method_name; FALSE if obj is not an object


call_user_method() provides an alternate syntax for calling object methods. This function is primarily useful as a way to dynamically call methods at runtime without requiring eval() .

Normally, methods are called with the following syntax:

$object->method ('arg one', 'arg two', ...);

Calling the same method using call_user_method() would look like this:

call_user_method ('method', $object, 'arg one', 'arg two', ...);


call_user_method() is deprecated (as of PHP 4.0.5). call_user_func() should be used in place of this function.

The following syntax for call_user_func() duplicates the functionality of call_user_method() :

call_user_func(array(&$object, 'method'), 'arg one', 'arg two', ...)


PHP Version: 3.0.3+, 4+

See also

To call a function in the same manner:


To pass a variable number of arguments to a method (or function):





Example 100. Call a member function using call_user_method()

class banana {
    var $peeled;

    function banana () {
        $this->peeled = FALSE; 

    function peel () {
       $this->peeled = TRUE; 

    function eat () {
        if ($this->peeled) {
           print 'Yum!';
        } else {
           print 'Bleck! Ever considered peeling your bananas <i>before</i> eating them?';

$banana = new banana ();

call_user_method ('eat', $banana);

PHP Functions Essential Reference. Copyright © 2002 by New Riders Publishing (Authors: Zak Greant, Graeme Merrall, Torben Wilson, Brett Michlitsch). This material may be distributed only subject to the terms and conditions set forth in the Open Publication License, v1.0 or later (the latest version is presently available at The authors of this book have elected not to choose any options under the OPL. This online book was obtained from and is designed to provide information about the PHP programming language, focusing on PHP version 4.0.4 for the most part. The information is provided on an as-is basis, and no warranty or fitness is implied. All persons and entities shall have neither liability nor responsibility to any person or entity with respect to any loss or damage arising from the information contained in this book.

Powered by: vBulletin Version 3.0.7
Copyright ©2000 - 2005, Jelsoft Enterprises Ltd.
Copyright © 2001 - 2005, ThinkDing LLC. All Rights Reserved.