5

I have this code in one of my classes

 public function __call($method, $args) {

        array_unshift($args, $method);

        call_user_method_array('view', $this, $args);

    }

We've since switched servers, and they must use a newer version of PHP5, and I get the following message

Function call_user_method_array() is deprecated

Is there where I should use reflection? What exactly is it, and how would I use it to modify my code above to work as it used to?

Charles
  • 50,943
  • 13
  • 104
  • 142
alex
  • 479,566
  • 201
  • 878
  • 984
  • Stack overflow users might be able to tell me things the manual does not. E.g. Best practices, tips etc – alex Jan 28 '10 at 12:09
  • "Function in PHP deprecated, what should I use now?" The answer you accepted and called "perfect" merely links to and quotes the manual. – GZipp Jan 28 '10 at 17:32
  • Well, in this case there wasn't anything extra to add, but it still solved my problem. Who ever said Stack Overflow shouldn't be a first place to find things out anyway? There are plenty of manual type questions on here. – alex Jan 28 '10 at 22:22
  • "There are plenty of manual type questions on here." I have to concede you that. – GZipp Jan 28 '10 at 22:30
  • There are plenty of manual type questions which have received more thorough answers. Take the "How do I get the PHP version" question. The answer `phpversion()` was brought up, but users added the benefits of using the constant, and the need to use `version_compare()` when trying to determine if a PHP package was suitable for an application. http://stackoverflow.com/questions/2113955 – alex Jan 28 '10 at 23:18

1 Answers1

24

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

The call_user_method_array() function is deprecated as of PHP 4.1.0.

New way:

<?php
// Old:
// call_user_method_array('view', $this, $args);
// New:
call_user_func_array(array($this, 'view'), $args);
?>
Thiago Belem
  • 7,732
  • 5
  • 43
  • 64