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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T17:56:04+00:00 2026-05-23T17:56:04+00:00

file1.php <?php $listMenu=array(‘Menu #1′,’Menu #2′,’Menu #3’); ?> <div class=wjNavButton><a><?php echo($listMenu[0]); ?></a></div> <div class=wjNavButton><a><?php echo($listMenu[1]);

  • 0
file1.php
<?php
$listMenu=array('Menu #1','Menu #2','Menu #3');
?>

<div class="wjNavButton"><a><?php echo($listMenu[0]); ?></a></div>
<div class="wjNavButton"><a><?php echo($listMenu[1]); ?></a></div>
<div class="wjNavButton"><a><?php echo($listMenu[2]); ?></a></div>


file2.php
$buff=include('file1.php');
$rest='[{sectionId:"LT", sectionType:"menu", sectionData="'.$buff.'"}]';
echo($rest);

result:
[{sectionId:"LT", sectionType:"menu", sectionData="1"}]

question:
- is this possible to put result of php page in variable?
- how i can result as output of file1.php and not sectionData="1"?
  • 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-23T17:56:04+00:00Added an answer on May 23, 2026 at 5:56 pm
    ob_start();
    include 'file1.php';
    $buff = ob_get_clean();
    
    $data = array(array('sectionId' => 'LT', 'sectionType' => 'menu', 'sectionData' => $buff));
    echo json_encode($data);
    
    • You can’t get the contents of a page using $buff = include. Imagine include as copy and pasting the contents of one file into another. It doesn’t return anything. (Unless you structure your include files differently so it does, read the documentation.)
    • You can capture and get the content using output buffering though.
    • Never write your own JSON, use json_encode to make sure your syntax is correct and values are escaped properly.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What I want do to is to include 'file1.php' from 'domain1' into 'file2.php' on
In many places in my code, I do things like: file1.php: <?php include('../file2.php'); file2.php:
file1.php and file2.php with die(); function. include.php: <? include 'file1.php'; include 'file2.php' ?> file1.php
I have a little problem. Here is my example: file1.php : <?php include(file2.php); ?>
I have the Index file like this <?php include('file1.php'); include('file2.php'); ?> in file1.php I
In file1.php , I execute file2.php with <form action=file2.php method=POST> Within file2, I want
I have 3 files (file1.php, file2.php and file3.php). Their contents are given below. When
vars.php <?php $sometext=text; ?> index.php <?php include ('file1.php'); include ('variables.php'); function genStr() { $len
Imagine I have the following situation: File1.php <?php include(Function.php); log(test); ?> Function.php <?php function
piece of file1.php: <a href=file2.php?addid=1>Add this to DB</a> This takes the user to 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.