If the Zend framework is object oriented, it is likely using exceptions, not errors. These are not the same, so error_get_last will work just not with exceptions. Exceptions only live to the catch, or force a termination if not caught.
Best you can do is retrieve the last assigned variable to the catch as PHP will not unset the assigned variable beyond the catch block.
In the code that I submitted, that is true, but there is also an error in the view that uses this layout - and I would expect that error to be picked up by error_get_last() once I remove the error that you see here.
The issue is that the error inmy view is not being found by error_get_last() in my layout.
Could it be that the controller runs the layout before it runs the view, so the error in the view has not yet occurred when the layout is run?
Its certainly possible; I know nothing of the zend framework. Objects can be tricky with this; there is nothing in place that says I cannot generate the output via referencing and populated it after the fact (kind of like the way prepared statements work when you bind results and variables to the statement). I can see this especially being the case should the output be something that is used repeatedly for different output.
I can't test this where I am. I wouldn't expect an inclusion to have any impact on the use of error_get_last as that would be linked prior to runtime. Another thing you *could* try is to use the $php_errormsg (with track_errors enabled in ini) as a reference. I don't know if it will work given the nature of the special $php_errormsg variable, but I know for sure it won't work for error_get_last. So you can't get a trace, only a message.
That would be a simple test as: