-2

Possible Duplicate:
Only variables can be passed by reference

I am having this error in php

Only variables should be passed by reference

and such warnings are displaying in millions of places. How can I off this error?

Community
  • 1
  • 1
Kutta
  • 95
  • 1
  • 4
  • 4
    Well, for one, you could write correct code :) – Alin Purcaru Feb 28 '12 at 16:27
  • Pass variables rather than values to the method/function that raises the problem - easy! PHP is trying to write a value to a value, which is impossible. – halfer Feb 28 '12 at 16:27
  • (This is a very searchable problem, by the way) – halfer Feb 28 '12 at 16:27
  • Downgrade your PHP to 4.4, or change the error reporting level, OR (even better) update your code! – ajreal Feb 28 '12 at 16:28
  • No, that is not a duplicate of this. This question wants the warning explained; the other is a design question about avoiding the issue in the first place (with foreknowledge of the warning's meaning). – Lightness Races in Orbit Feb 28 '12 at 16:29
  • it was working on local machine. But after uploading to remote machine this warning is displaying. I can not change whole code neither i can change php version – Kutta Feb 28 '12 at 16:31
  • @Kutta: What decision process did you go through when deciding to upload to a machine running a different PHP version? – Lightness Races in Orbit Feb 28 '12 at 16:35

1 Answers1

3

By only passing variables by reference, not other things.

The "other things" in this case may well be the result of function calls, which are not variables.

e.g.

array_pop(Array(1,2,3,4));

array_pop takes a reference, but Array(1,2,3,4) is not a variable and only variables can be passed by reference.

I'd be able to give a better answer if we had any idea what even one of the pieces of your code looked like.

Lightness Races in Orbit
  • 378,754
  • 76
  • 643
  • 1,055