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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T10:39:38+00:00 2026-05-15T10:39:38+00:00

I’m attempting to file_get_contents and output php code as a string without being rendered.

  • 0

I’m attempting to file_get_contents and output php code as a string without being rendered. The idea is to grab the raw un-rendered file contents so they can be edited in a textarea…

// file "foo.php" I'm needing the contents of
<h1>foo</h1>
<? include 'path/to/another/file' ?>

// php file that's calling the file_get_contents
<?php
    echo file_get_contents('foo.php');
?>

The above code is stripping out the php include in foo.php which outputs:

<h1>foo</h1>

Does anyone know how I can get foo.php contents as a raw un-rendered string where output will be?:

<h1>foo</h1>
<? include 'path/to/another/file' ?>

Any help is greatly appreciated!

  • 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-15T10:39:38+00:00Added an answer on May 15, 2026 at 10:39 am

    As far as I know you can’t get php content unless it’s on the same server.
    Make sure you’re trying to access a locally hosted file and not something remote and it should work.

    Also if you try to echo code it will try to parse it, so pass it through htmlspecialchars($source) and it should work.

    Something like this:

    <?php
        echo "<pre>";
        echo htmlspecialchars(file_get_contents('file.php'));
        echo "</pre>";
    ?>
    

    Would echo formatted source code of the php file, including comments and any other text in it without being parsed. And since it looks like it’s important to you, I’d also say that it shows in the DOM of course since it’s no longer code, now it’s text. You can place it inside a container, style it and do whatever you want with it.

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

Sidebar

Ask A Question

Stats

  • Questions 428k
  • Answers 428k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer As Spidey says just use 0xFFFFFF - COLOR. In ActionScript… May 15, 2026 at 1:23 pm
  • Editorial Team
    Editorial Team added an answer Javascript is a string of text. Databases can store strings… May 15, 2026 at 1:23 pm
  • Editorial Team
    Editorial Team added an answer First of all, cacheColorHint has nothing to do with style.… May 15, 2026 at 1:23 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.