PHP: Adding variables in the current scope
by Ashish DattaSo earlier today I was working on a Facebook App and wanted to use “partials” in a similar fashion as Symfony’s partials. At this point, I realized I had no idea how Symfony placed variables into the current execution scope when you do things like
include_partial("somePartial", array("foo" => $foo, "bar" => $bar));
A bit of digging led me to the extract() function in PHP.
From the documentation, “extract — Import variables into the current symbol table from an array”.
Pretty neat.

February 8th, 2010 at 11:15 am
..or within the partial:
$sf_view->getAttribute(‘foo’);
$sf_view->setAttribute(‘foo’,$foo);
$sf_view->getAttributeHolder()->getAll();