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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T15:12:19+00:00 2026-06-12T15:12:19+00:00

Possible Duplicate: Problem when loading php file into variable (Load result of php code

  • 0

Possible Duplicate:
Problem when loading php file into variable (Load result of php code instead of the code as a string)

I am trying to create a template based application and I am having issues writing the user data into a pre-existing template file.

I would initially use file_get_contents('template.php');

and template.php would contain the following:

echo $user;

Is there anyway to insert data into a placeholder variable in a template file using file_get_contents?

I suppose I could use DomDocument or regex to insert the data into a placeholder string, but would this be possible to do with a php variable?

  • 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-12T15:12:21+00:00Added an answer on June 12, 2026 at 3:12 pm

    If you have control over template.php and are aware of the security considerations, you’re probably looking for include or require:

    include('template.php');
    

    Will do what you want to do.

    EDIT

    Output buffering

    ob_start();
    include('template.php');
    $result = ob_get_clean();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Problem when loading php file into variable (Load result of php code
Possible Duplicate: Dynamically loading an external CSS file I'm trying to create a dynamic
Possible Duplicate: Problem executing bash file I have created a bash file script and
Possible Duplicate: C++ std::string conversion problem on Windows How to convert std::string to LPCSTR?
Possible Duplicate: problem with template inheritance This code doesn't compile in GCC: template <typename
Possible Duplicate: Java GUI repaint() problem? I write a Java code, but I have
Possible Duplicate: Solution to a recursive problem (code kata) give an algorithm to find
Possible Duplicate: WPF Button isPressed and isEnabled problem Here is a snippet of code
Possible Duplicate: Parse XML with Namespace using SimpleXML PHP SimpleXML Namespace Problem <?php header(Content-Type:
Possible Duplicate: PHP Integer Problem 1.0000241703257e+14 how to convert it in PHP, it was

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.