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?

3
  • 6
    try $filename_arr = explode("/", $_SERVER['SCRIPT_FILENAME']); $filename = array_pop($filename_arr); Commented Sep 23, 2012 at 14:47
  • 1
    array_pop expects a variable as it tries to remove the last item from it. Commented Sep 23, 2012 at 14:48
  • possible duplicate of Strict Standards: Only variables should be passed by reference Commented Jun 21, 2014 at 8:40

1 Answer 1

3

Breaking the code apart would resolve the error

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

echo $filename ;

Demo Break Apart

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.