Internet Resource

Solved:Only variables can be passed by reference in functions.php

php5
Today, I install this wordpress named KeKo, When my site run on php4, it’s OK, but when I update php4 to php5, this theme get an error:

Only variables can be passed by reference in functions.php line 17

And the line 17 codes is:

$comments_by_type = &separate_comments(get_comments(‘post_id=’ . $id));

Yes, it’s a bug of php5, you can fix this bug like this:

$tmp = get_comments(‘post_id=’ . $id); $comments_by_type = &separate_comments($tmp);

The bug mentioned above is also present in version 5.0.5 and affects a range of functions:

The following code will generate an error:
return end(explode(” “, $host));
The fix:

$tmp = explode(” “, $host); return end($tmp);

——————————————————————————–

And this:
list($parent, $num) = each(end($this->tags));
These are actual examples that needed to be patched on our system – I think you can see the pattern 😉

——————————————————————————–

This will also error:
$category = array_shift(array_keys($categories));
The fix:

$tmp = array_keys($categories); $category = array_shift($tmp);