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 7169177
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T14:56:00+00:00 2026-05-28T14:56:00+00:00

i was bitten by some ABSTRACTION & ORGANISATION bug and i decided that i

  • 0

i was bitten by some ABSTRACTION & ORGANISATION bug and i decided that i would include files in my php application by using a class called Loader which looks like this

class Loader
{
    public $loadedFiles=array();

    public function isLoaded($fileName)
    {
        if(in_array($fileName,$this->loadedFiles))
        return true;
        else 
        return false;
    }

    public function load()
    {
        $fileList=func_get_args();
        foreach ($fileList as $file)
        {
            if(!$this->isLoaded($file))
            {
                $flag=include(ROOT_DIR_PATH.'includes'.DS.$file);
                if($flag)
                {
                    $this->loadedFiles[]=$file;

                }
                else
                return false;
            }
        }
    }
}

Now i can include files in my app using something like this

$loader=new Loader();
$loader->load('db.class.php','utility.php','objects.php');

but the problem is that now all the functions of the files included by the above method are granted the scope of the above method load. now i cant use any functions of the included files . Whenever i use any function of the above included files i get a warning saying undefined function. Is there some way i can grant global scope to the functions of the included 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-05-28T14:56:02+00:00Added an answer on May 28, 2026 at 2:56 pm

    Looks like the problem is somewhere else. I have tried to simulate what you were trying to do and it worked for me.
    include1.php

     <?php
     function tester()
         echo "This is tester\n";
     }
    

    include2.php

    <?php
    
    class Loader {
        public function load() {
            $var = include('include1.php');
        }
    }
    
    $loader = new Loader();
    $loader->load();
    tester();
    

    And the result was this: This is tester

    There wasn’t any scoping issue. As @JackTurky mentioned, check the path.

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

Sidebar

Related Questions

I've just been bitten by an annoying bug that was made obscure by the
I believe I'm getting bitten by some combination of nested scoping rules and list
I've recently been bitten by the javascript:void(null); bug in my hrefs when applied to
Encoding issues are among the one topic that have bitten me most often during
I need to ensure that any number of websites and services haven't bitten the
We have a .properties file that has some values persisted as JSON. I keep
Several times (even several in a row) I've been bitten by the defaultdict bug:
I'm using Autocomplete UI . I have some ploblems with results of a database
I have a URL class that overloads the ==, <, >, and != operators
I have an old (around 5 years) enterprise application that I manage. Recently we

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.