Reputation: 2727
This is part of a drupal module and I am getting this error:
Strict warning: Only variables should be passed by reference in customheaderimage_get_last_argument()
My code is
function customheaderimage_get_last_argument() {
return customheaderimage_dashtoslash(array_pop(explode('/', $_GET['q'])));
}
q contains a value like "admin/configure/customheaderimage/edit/node--2" the dashtoslash changes the -- to a slash with str_replace. so all of those chained functions return something like 'node/2' and it currently does and works. Just throws this warning
How do I resolve this warning message it does this in a few places?
Upvotes: 0
Views: 111
Reputation: 20873
array_pop()
takes an argument by reference:
mixed array_pop ( array &$array )
It needs the reference because it modifies the array passed in as the argument. You're passing the result of a function and not a variable, so the reference doesn't make sense. In other words, you need to pass a variable as the argument.
function customheaderimage_get_last_argument() {
$arr = explode('/', $_GET['q']);
return customheaderimage_dashtoslash(array_pop($arr));
}
Upvotes: 2