I am looking to come up with a function which will return based on how it is called.
If I call the function from within a php class or function, it will return an array, whereas if it was called from within an eval() statement then it will return a string.
Say the function is as:
function GetName(){
return isEval ? 'John Doe' : array('John','Doe');
}
Is it possible to replace the isEval with something to detect if it was called from within eval() ?
Update:
This is going to be part of a CMS system. I need to provide some already builtin functions to become available publicly. I know the security risks would arise using eval(), but still would like to know if it is possible in anyway.
Passing in parameter for sure works perfectly, but as described above, dont want to get abused by providing that option.
The only function that contains information you want is
debug_backtrace. So you can do something like: