title: Only variables can be passed by reference
body: <p>I had the bright idea of using a custom error handler which led me down a rabbit hole.</p>
  
  <p>Following code gives (with and without custom error handler): <strong>Fatal error: Only variables can be passed by reference</strong></p>
  
  <pre><code>function foo(){
      $b=array_pop(array("a","b","c"));
      return $b;
  }
  print_r(foo());
  </code></pre>
  
  <p>Following code gives (<strong>only with a custom error handler</strong>): <strong>(2048) Only variables should be passed by reference</strong></p>
  
  <pre><code>function foo(){
      $a=explode( '/' , 'a/b/c');
      $c=array_pop(array_slice($a,-2,1));
      return $c;
  }
  print_r(foo());
  </code></pre>
  
  <p>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.</p>
  
  <p>Anyone with better ideas? Also, WTF?</p>
  
  <p><strong>UPDATE</strong>:</p>
  
  <p>Thanks to the answers I've learnt something about how php does error handling. The confusion of E_ALL not including E_STRICT (php 5) is not cool.</p>
  
  <p>On top of all this, creating your own custom error handler enables E_STRICT by default and thats where problems start.</p>
  
  <p>The moral of the story is to use your own error handler to catch them ALL and use the error constants (E_STRICT, E_USER_WARNING, E_USER_ERROR, etc.) to do your filtering.</p>
  
  <p>As for the 'memory corruption issue' with variable references and certain functions, what can I say? Doubly uncool. I'll (which doesn't mean you should) ignore E_STRICT in my error handler and life goes on.</p>