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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T19:06:06+00:00 2026-06-10T19:06:06+00:00

Here is a situation. I want to duplicate an API twice on my server

  • 0

Here is a situation.

I want to duplicate an API twice on my server but with different databases. What I want to do is to use some function of these API’s. In PHP I have a situation where I am implmenting a loop of all these API locations.

forach($apis as $api){
 include ($api->apiFiles);
 useAPIfunction();
}

the problem is The API have the same functions and classes, the loop runs one time but for the second time the PHP Fatal error cannot redeclare function” occurs.

Now I don’t want to change the API like changing function names etc, I have to do all from my script. Is there a situation to unregister the API file after the first iteration completed because it is the only way to include the new API.

Thanks in Advance for Help.

  • 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-10T19:06:07+00:00Added an answer on June 10, 2026 at 7:06 pm

    I have done a trick. I included the API files on the first iteration and then for other iteration add a script to connected to the second database and vice verse. Now the API will be connected once using the first API files but the Database is changing on new iteration. Also I did not found a way to get The Database Info so I retrieved it from the API config file.

    forach($apis as $api){
     if($count = 0){
      include ($api->apiFiles);
     }else{
      $theData = file_get_contents($api->path'\includes\config.php', NULL, NULL, 10, 600);
      $theData = str_replace('<?php','',$theData);
      $theData = explode("'",$theData);
      $apiHost = $theData[19];
      $apiDB = $theData[7];
      $apiDbUser = $theData[11];
      $apiDBPass = $theData[15];
    
      mysql_connect($apiHost,$apiUser,$apiPass);
      mysql_select_db($apiDB);
     }
     useAPIfunction();
    

    }

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

Sidebar

Related Questions

Here's my situation: I have a file, homepage.php, that I want to allow my
So here's the situation. I want to make a simple game for android. It's
I want to have a page redirect to another. Here is the situation: I
Unix command find doesn't do what I want to do. Here is the situation
I got a little confusing situation here when I use the Context from django.template.
I have a situation here there are two models User,Posts Now I want to
Here's my situation: I want stuff under mysite/customer/* to require form-based authentication before access
Here's the situation: I want an element to appear on top of a link
I may have a unique situation here. I want gVim (gui version, in Linux)
Here's the situation. What I am working with: - ASP.NET MVC 4 Web API

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.