That won't be a scope issue. That sounds like an order of execution issue. error_get_last should work independently of any scope:
will result in
[type] => 8
[message] => Undefined variable: var
[file] => /t.php
[line] => 7
So the problem is that the error is triggered sometime after the processing has occurred where you have put it.