Sunday, July 12, 2015

Strict Standards: Only variables should be passed by reference in...

Recently I switched my web hosting service to some new providers, one of the websites is having a little minor problem. The error message was "Strict Standards: Only variables should be passed by reference in... some file... some line..."

The line that had the problem:

$ext = strtolower(end(explode('.', $image_path)));

Not sure for real or not, some folks suggest that this little problem could cause a memory leak, and memory leak can eat up memory which can not be reclaimed till the script finishes. Or in some cases it can not be reclaimed until the server restarts. Little bit of this and that of memory leak can add up gradually and bring a healthy server to a crawl. Wow, sounds serious eh?

Anyway, the suggested way to fix it is really simple:

$tmp = explode('.', $image_path);
$ext = end($tmp);
$ext = strtolower($ext);

After the little modification, my website works again. Well, I guess this new provider is a bit more strict on things than the previous one.