Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Function in PHP deprecated, what should I use now?

Tags:

php

deprecated

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?

like image 419
alex Avatar asked Jan 27 '10 23:01

alex


1 Answers

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);
?>
like image 84
Thiago Belem Avatar answered Oct 04 '22 04:10

Thiago Belem