Does eval() create a seperate parsing instance? to clear up the question are any variables function and classes not available within the eval() function? the reason I ask is because out of curiosity I created this...
Does eval() create a seperate parsing instance? to clear up the question are any variables function and classes not available within the eval() function?
No, eval simply evaluates the code string as if it were hard-coded at that point in the script -- the variables, functions, etc. are all available in the current scope just like regular code.
Your function seems a little odd. What would the advantage be of calling $object->t_display('blah') over $object->template->display('blah')? The former seems (to me) counter-productive since you're in essence breaking down the owner/member object relationship... in broad terms you're calling a method (function) "belonging" to $object when that method actually doesn't (shouldn't) belong to it; display belongs to template, not to the $object directly. But that's an aside, and I'm sure you have perfectly valid reasons for taking this particular approach.
There are a number of things that I don't particularly feel are good approaches in your function, but since you didn't ask for comments on the actual code, I'll leave those out of this post. I would like to say however that you can use call_user_func_array as an alternative to eval. Say for example that the string which you would have evaled turned out to be: $this->template->display('blah', 'moo'); then you can use call_user_func_array in the following manner: