Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7835223
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T13:33:35+00:00 2026-06-02T13:33:35+00:00

In codeigniter templates are basically include files and template input is made available by

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T13:33:36+00:00Added an answer on June 2, 2026 at 1:33 pm

    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:

    $foo = 'bar';
    $data = array('foo' => 'baz');
    
    foreach($data as $key => $val)
        if(isset($$key)) { /* throw fatal error */ }
    
    $this->load->view($data);
    

    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.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any netbeans code templates available for codeigniter ? Like : http://abechik.wordpress.com/2008/10/08/netbeans-php-code-template/
How can CodeIgniter and WordPress be integrated such that the look and feel/template of
Using PHP and/or Codeigniter, I want to create some string templates to be store
I followed this tutorial: http://codeigniter.com/wiki/Internationalization_and_the_Template_Parser_Class/ The controller that loads the language is this one:
I'm new to CodeIgniter. I've been loading common templates like header and footer in
If CodeIgniter has _remap() that gets called before it touches any method in a
I'm just learning codeigniter, and I seem to have run into something that is
I need 3 different templates for my Codeigniter application. I had read about Themes'
I am using the Template library for Codeigniter and if I leave template->title blank,
Hello all im using this template system http://williamsconcepts.com/ci/codeigniter/libraries/template/index.html but now i want to add

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.