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 er
array_pop()
changes that value passed to it which is where the error is coming from. A function cannot be changed. In other words, you need to assign the array to a variable first (ref: manual), and then run array_pop()
.
The code you need is this:
function foo(){
$a = array("a","b","c");
$b = array_pop($a);
return $b;
}
Edit: Both functions you mentioned have the same problem. Assign the array to a variable and pass the variable to array_pop()
.