In codeigniter templates are basically include files and template input is made available by associative arrays. I guess codeigniter uses extract() for that part of the magic, but how does it prevent those variables to mess up the global scope? Or am I missing something with variable scope in include files?
In codeigniter templates are basically include files and template input is made available by
Share
It does indeed use extract(). While the extract function has an option not to overwrite existing variables, by default it does overwrite, and CodeIgniter uses this default.
Since the view is ostensibly the final endpoint of your application, and should not use any variables except what you pass through the view, it is intended that this should not present any issues. However, if you wish to catch scope collisions, you can do something like this:
To answer your question in a more technical and less practical way, the commenter above is correct: variables resolve within the method scope of the _ci_load function, inside the CI_loader class.