tags:

views:

39

answers:

1

I have an class with some instance variables. It's purpose is for templating.

So this class has a fetchTemplate() method which includes a PHP template file.

In my template file, I can access any variable that has been assigned to the template, by writing:

echo $this->theVariable

If there was a way to "pull" all arbitrary instance variables into the local variables scope of fetchTemplate(), it would be possible to simply write:

echo $theVariable

I slightly remember that there was something....

A: 

You can cast the object to an array and use extract():

extract( (array)$this );

but I think it will just work on public variables.

kemp