0

I have upgraded PHP from v5.3 to v5.4 and I am now getting the following error:

Strict standards: Only variables should be passed by reference

Code:

$filename = array_pop(explode("/", $_SERVER['SCRIPT_FILENAME']));

How to fix this?

Nikola K.
  • 7,093
  • 13
  • 31
  • 39
I'll-Be-Back
  • 10,530
  • 37
  • 110
  • 213
  • 6
    try `$filename_arr = explode("/", $_SERVER['SCRIPT_FILENAME']); $filename = array_pop($filename_arr);` – air4x Sep 23 '12 at 14:47
  • 1
    `array_pop` expects a variable as it tries to remove the last item from it. – Gumbo Sep 23 '12 at 14:48
  • possible duplicate of [Strict Standards: Only variables should be passed by reference](http://stackoverflow.com/questions/2354609/strict-standards-only-variables-should-be-passed-by-reference) – Lorenz Meyer Jun 21 '14 at 08:40

1 Answers1

3

Breaking the code apart would resolve the error

$filename = explode("/", $_SERVER['SCRIPT_FILENAME']);
$filename = array_pop($filename);

echo $filename ;

Demo Break Apart

Baba
  • 94,024
  • 28
  • 166
  • 217