Possible Duplicate:
Annoying PHP error: “Strict Standards: Only variables should be passed by reference in”
I have this line of code,
$extension=end(explode(".", $srcName));
when I fun my function I get
PHP Strict Standards: Only variables should be passed by reference in
I am not sure how to solve this
The function end()
requires a variable to be passed-by-reference and passing the return-value of a function doesn't acheive this. You'll need to use two lines to accomplish this:
$exploded = explode(".", $srcName);
$extension = end($exploded);
If you're simply trying to get a file-extension, you could also use substr()
and strrpos()
to do it in one line:
$extension = substr($srcName, strrpos($srcName, '.'));
Or, if you know the number of .
's that appear in the string, say it's only 1, you can use list()
(but this won't work if there is a dynamic number of .
's:
list(,$extension) = explode('.', $srcName);