How to check, if a line of code, that is actually being executed runs from inside of eval() function? Did anyone have to deal with something like this?
2 Answers
I'd like to thank Ryan Vincent for his advice!
function is_eval()
{
$debug = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
foreach ($debug as $step => $trace) {
// ignore class calls
if (isset($trace['class'])) {
continue;
}
if (isset($trace['function']) && 'eval' === $trace['function']) {
return true;
}
}
}
1 Comment
Leandro Jacques
How does it work? When should I call is_eval function? It's not very clear to me.
evalfunction, see docs here php.net/manual/en/function.override-function.phpvar_dump()works perfectly fine ineval(). Problem is that I have to distinguish, if a library is being executed from inside aneval()while running. I've tried the global variable solution, but insideeval()you've got an access to the same variables as from outside.