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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T01:38:26+00:00 2026-06-01T01:38:26+00:00

I need to display the content of another page from a function using return.

  • 0

I need to display the content of another page from a function using return.
What is the best way to do this?

Say that I have file.php. In my script in another page, I want to call a function and return the contents of file.php.

For example:

myFunction() {
  $page = WHAT('file.php');
  return $page;
}

What to use in place of ‘WHAT’? I’ve tried include, because it’s what I know, but it doesn’t work here.

EXTRA NOTES: This is used in a Drupal module. The admin theme / menu displays as normal if I use $page = 'insert code here'; return $page; – but not if I use $page = include('file.php'); because the function doesn’t even use the return when it sees 'include'.

  • 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-01T01:38:27+00:00Added an answer on June 1, 2026 at 1:38 am
    1. for code or content of file use: file_get_contents

    2. for instant result of another php page, you can try ob_start and ob_get_clean.

    It will gather the output of the included file in memory and later you can gather the output to variable and clean the memory or just show the output directly.

    like:

    myFunction(){
       ob_start();
       include('file.php');
       $page = ob_get_clean();
       return $page;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a page, with a navigationbar that loads content, from another page, into
I need to display content from an OLAP cube in Sharepoint. This could be
I need ability to display content in Hex View, like this from WinHex Offset
In my webapp I have a page called display.php. The script in this page
I'm a newbie in CSS layout. I need to display content like this: +-------------------------------------+
I need to display the log entries from a database. Of course the log
I need to display 2d images in opengl using textures. The image dimensions are
I have some pages that have content that is relevant to both logged in
I have a bunch of texts and images (taken from the content tag of
Briefly, I need to create a server whose back end queries information from another

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.