3

i am using php script got from torrenteditor to create torrent files , but when i create new torrent files, using specified method, torrent files gets created but i get lots of notices ., like this

Only variable references should be returned by reference in myfile.php on line 319

on this line

return new BEncode_End();

which is specified as another class as

class BEncode_End
{
    public function get_type()
    {
        return 'end';
    }
}

so how can i fix this notices ?

i am pretty new to classes , so dont know where to start.

complete script/code uploaded here http://pastebin.com/L6ktvrne , line 319

i am using

ini_set('display_errors', 1); 
error_reporting(E_ALL);
  • `error_reporting(0);` fixes it – adeneo Jun 28 '15 at 06:14
  • @adeneo i guess, it doesnt fixes, it , it ignores/ hides it, thanks i am looking for fix , so i can use this in production and not worried about ignoring other notices too, –  Jun 28 '15 at 06:15
  • Based on http://stackoverflow.com/questions/28348879/only-variable-references-should-be-returned-by-reference-codeigniter try: `$cl = new BEncode_End(); return $cl;` – Ofir Baruch Jun 28 '15 at 06:18
  • @OfirBaruch strange, it did fixed the issue of notices. Thanks. –  Jun 28 '15 at 06:24
  • Would it be ok if I'd add it as a solution for your approval? – Ofir Baruch Jun 28 '15 at 06:33
  • @OfirBaruch yes, please. you have a GO. –  Jun 28 '15 at 06:34

1 Answers1

4

Based on the notice you get and on an answer to another related question:

In PHP assignment expressions always return the assigned value. So $_config[0] =& $config returns $config - but not the variable itself, but a copy of its value. And returning a reference to a temporary value wouldn't be particularly useful (changing it wouldn't do anything).

Changing your code from:

return new BEncode_End();

To:

$cl = new BEncode_End();
return $cl;

Should solve your problem.

Community
  • 1
  • 1
Ofir Baruch
  • 9,897
  • 1
  • 23
  • 37
  • It indeed solved my problem, and i even fixed more occurrences of similar code., thanks –  Jun 28 '15 at 06:47