Re: How do I know if the code is in eval?

From: Date: Wed, 23 Jul 2014 16:38:52 +0000
Subject: Re: How do I know if the code is in eval?
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-75967@lists.php.net to get a copy of this message
On Tue, Jul 22, 2014 at 7:23 PM, Aaron Lewis <the.warl0ck.1989@gmail.com> wrote: > > How can I know the line no in eval()'d code? > Are you asking how to determine where the eval'd code was called from? There's a way, but it's a bit messy: Walk up EG(current_execute_data) until you get to the opline pointing at ZEND_EVAL (this will probably be the current stack, or one above, depending on where your error got thrown from). opline->lineno will have the line number where eval was called from. You can take a look at the implementation for debug_backtrace() for inspiration if need be. Just bear in mind that eval() is an op, not a function. > Also, I'm not sure how to tell if the code is in eval() either > As Derick mentioned, the "executed file" is a good hint. Though if you're walking up the execute data already, you'll probabaly notice the ZEND_EVAL instruction along the way. -Sara

« previous php.internals (#75967) next »