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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T11:00:34+00:00 2026-06-07T11:00:34+00:00

Well, I don’t know if this post have the correct title. Feel free to

  • 0

Well, I don’t know if this post have the correct title. Feel free to change it.

Ok, this is my scenario:

pluginA.php

function info(){
   return "Plugin A";
}

pluginB.php

function info(){
   return "Plugin B";
}

Finally, I have a plugin manager that is in charge of import all plugins info to pool array:
Manager.php

class Manager
{
    protected $pool;

    public function loadPluginsInfo()
    {
        $plugin_names = array("pluginA.php", "pluginB.php");

        foreach ($plugin_names as $name) 
        {
            include_once $name;
            $this->pool[] = info(); 
        }
    }
}

The problem here is that when I print pool array it only show me the info on the first plugin loaded. I supposed that the file inclusing override the info because it still calling the info() method from the first include.

Is there a way to include the info of both plugins having the info() function with the same name for all plugins files?

Thank you in advance

PS: a fatal cannot redeclare error is never hurled

  • 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-07T11:00:36+00:00Added an answer on June 7, 2026 at 11:00 am

    you can use the dynamic way to create plugin classes

    plugin class

    class PluginA
    {
        public function info()
        {
            return 'info'; //the plugin info
        }
    }
    

    manager class

    class Manager
    {
        protected $pool;
    
        public function loadPluginsInfo()
        {
            $plugin_names = array("pluginA", "pluginB"); //Plugin names
    
            foreach ($plugin_names as $name) 
            {
                $file = $name . '.php';
                if(file_exists($file))
                {
                    require_once($file); //please use require_once
                    $class = new $name(/* parameters ... */); //create new plugin object
    
                    //now you can call the info method like: $class->info();
                }                
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Well I don't know correct word for this so I wrote three of them,
Well i need some help here i don't know how to solve this problem.
I don't know if this is a well known 'thing' or something new in
Hey, well I don't really know how to describe this but here's my current
Paint.net dies opening this image, and MS paint as well.I don't know how to
I don't understand MEF very well, so hopefully this is a simple fix of
I don't know MySQL very well so I need a bit of help with
I don't understand very well this code: var img = $('<img/>', {class: photo, src:
Well. I don't really know if what I want is possible by the way
Well, I don't know if I'm completely wrong, but I really can't find a

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.