We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Partial params change global vars

I'm migrating to php7. Phalconphp version now is 3.3.2, PHP Version 7.0.28-0ubuntu0.16.04.1.

Problem: In some view file example.phtml

<?

$id = 100;

$this->partial('example_partial',['id'=>777]);

print 'In view '.$id;

?>

In example_partial.phtml:

<?='In partial'. $id;?>

Used to be (which was correct imho):

In partial 777 In view 100

Now:

In partial 777 In view 777

So in the partial var "$id" has been changed for main view...

It doesn't look correct... In the docs we can see

"The partial() method does accept a second parameter as an array of variables/parameters that only will exists in the scope of the partial:"

It will be a big job to refactor and check all the code I allready have... may be there is some desicion

Maybe somebody can help me out?

yes this is an issue, better use macros



43.9k

Hey ! That is good to know.