Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

173
Views
File content not getting displayed correctly in div

I'm trying to display the content of a php file to a div.

<div contenteditable="true" id="highlight">
<?php
echo file_get_contents( "/path/test.php" );
?>
</div>

test.php

<?php
require_once (lib.php');

/*
some comments here
*/
session_cache_limiter('private, must-revalidate');
header('Pragma: public');
@ob_start();
@session_start();

error_reporting(E_ALL);
ini_set('display_errors', '1'); 

// INCLUDES
define('FPDF_FONTPATH', "path/font/");
// print_r($_GET);
?>
.......................

But the content in the div is displaying from this line only : // print_r($_GET);. I need to display the entire content of the file.

Can anyone help me to fix this? Thanks in advance.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Because the HTML parser of your browser sees <?php as an HTML element it will be commented out. You have to convert < and > to their equivalent HTML entities.

You can do this using htmlspecialchars (using <pre></pre> to keep the new lines from the actual file):

<div contenteditable="true" id="highlight">
    <pre><?php // this should be directly after pre to prevent white-space from appearing before the code from the file
        echo htmlspecialchars(file_get_contents( "43677696_test.php" ));
    ?>
    </pre>
</div>

You can see the output here.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!