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

  • Home
  • SEARCH
  • 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 8934773
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T09:51:39+00:00 2026-06-15T09:51:39+00:00

Usually when I want to create new content in a php file and implement

  • 0

Usually when I want to create new content in a php file and implement it somewhere in my site I do something like this (JS and PHP):

    case 'someCasename':
    ...
    include_once 'file.php';
    break;

...
success: function(data){
    $("#idSelector").html(data);
}

and the new content is displayed at the selected element.

But im curious on if its possible to send multiple php files at the same time. Not sure if this is really necessary and I’ve not come across a single time where I need to do this but I thought of the it and wanted to ask. This last code is most likely very very wrong but I just want to showcase what i mean:

    case 'someCasename':
...
$phpArray = array("file1" => include_once 'file1.php', "file2" => include_once 'file2.php', "file3" => include_once 'file3.php'):
echo $phpArray;
break;

...
success: function(data){
    $("#idSelector").html(data.file1);
    $("#idSelector").html(data.file2);
    $("#idSelector").html(data.file3);
}

Is something like this even remotly possible? You cant json_encode php files can you?

  • 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-15T09:51:40+00:00Added an answer on June 15, 2026 at 9:51 am

    If I understand you correctly, your included php file echo out something that you want to use in the success function of the ajax call.

    What you could do, is loop through all your includes and use output buffering to capture the output of these files in an array.

    Something like:

    case 'someCasename':
      ...
      $results = array();
      while (files_to_include)
      {
        ob_start;    // start output buffering
        include_once "your_file";
        $results[] = ob_get_clean();    // get the contents of the output buffer
      }
      echo json_encode($results);    // send all collected output as json to be used on the js side
      break;
    

    Although this would work, it would of course be better to use functions that return values in your includes instead.

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

Sidebar

Related Questions

New Android developer here - I'm hoping this is simple. I want to create
I want to create a config.php file to keep the various configuration values that
What I usually do is create a new file in the solution where I
Usually when one wants to create a new file in the Eclipse IDE ,
I want some code to be triggered every second. Usually, I'd create a Timer
I usually write python in emacs. I'll often want to re-evaluate my file, which
I installed PostgreSQL on my windows 7 desktop. Usually PostgreSQL will create new account
I have a file that looks like this (but is much bigger): >some text
I have seen examples containing things like this: mountSharedResource(/images/logo.gif, new ResourceReference(ImageScope.class, logo.gif).getSharedResourceKey()); mountSharedResource(/resource, Application.class.getName()
I am fairly new to JSON and I want to create a choropleth example

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.