Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Call-time pass-by-reference has been deprecated [duplicate]

Tags:

php

kohana

Possible Duplicate:
Call-time pass-by-reference has been deprecated;

My Kohana site, get this alert in libraries file.

Call-time pass-by-reference has been deprecated

Thats problem line:

call_user_func('Formo_'.$name.'::load', & $this);

How can i solve this?

like image 779
Karmacoma Avatar asked Dec 27 '22 00:12

Karmacoma


2 Answers

Remove the & before $this.

PHP5 doesn't need that added - all objects are passed as object identifiers by default, no need to mimic this with passing by reference as it was required for PHP 4.

like image 148
damianb Avatar answered Jan 13 '23 11:01

damianb


To pass a variable by reference in php5 you need to have & on your function declaration. NOT when you are calling the function.

function call_user_func($param1, &$param2) {
  // $param2 will be a reference
  // as mentioned by damianb though objects are by default references
  // http://php.net/manual/en/language.oop5.references.php

}

when calling this just pass in your params as normal and param2 will be passed by reference.

http://php.net/manual/en/language.references.pass.php

The above link clearely explains the error.

Note: There is no reference sign on a function call - only on function definitions. Function definitions alone are enough to correctly pass the argument by reference. As of PHP 5.3.0, you will get a warning saying that "call-time pass-by-reference" is deprecated when you use & in foo(&$a);.

like image 41
dm03514 Avatar answered Jan 13 '23 12:01

dm03514