Jump to content

problems with extract


Buyocat

Recommended Posts

EDIT I see I am in the wrong forum, my apologies, if someone with the rights could move me to the PHP Help forum that'd be perfect

 

I am trying to make a simple templating class, and I wanted to use extract($data) to get the variables set for the template.  I found an example that seems to extract like I want to, but my implementation fails -- it seems like the values extracted have the same scope as the function extract is called in (i.e. they can only be accessed by the function).  Let me show you what I have:

 

extract($this->_data);
      ob_start();
      include $this->_template; 
$template = ob_get_clean();

 

Suffice to say that I am positive that _data and _template are set and so not the problem.  I can echo out values extracted from _data in the function, but no in the include, and not outside the function (say after the class).  Any help would be appreciated, and I'm not stuck on using extract if there is an elegant alternative.

 

Thanks, Buyo

Link to comment
https://forums.phpfreaks.com/topic/45359-problems-with-extract/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.