Only variables can be passed by reference

Posted by zaf on Stack Overflow See other posts from Stack Overflow or by zaf
Published on 2010-06-03T15:50:45Z Indexed on 2010/06/03 15:54 UTC
Read the original article Hit count: 266

I had the bright idea of using a custom error handler which led me down a rabbit hole.

Following code gives (with and without custom error handler): Fatal error: Only variables can be passed by reference

function foo(){
    $b=array_pop(array("a","b","c"));
    return $b;
}
print_r(foo());

Following code gives (only with a custom error handler): (2048) Only variables should be passed by reference

function foo(){
    $a=explode( '/' , 'a/b/c');
    $c=array_pop(array_slice($a,-2,1));
    return $c;
}
print_r(foo());

The second one worries me since I have a lot of 'compact' code. So, I either ditch the bright idea of using a custom error handler (to improve my logging module) or expand all my code.

Anyone with better ideas? Also, WTF?

© Stack Overflow or respective owner

Related posts about php

Related posts about error-handling