Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

175
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda