I'll-Be-Back
I'll-Be-Back

Reputation: 10828

Variable reference error in PHP

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?

Upvotes: 0

Views: 127

Answers (1)

Baba
Baba

Reputation: 95101

Breaking the code apart would resolve the error

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

echo $filename ;

Demo Break Apart

Upvotes: 3

Related Questions