Estoy tratando de mostrar el contenido de un archivo php en un div.
<div contenteditable="true" id="highlight"> <?php echo file_get_contents( "/path/test.php" ); ?> </div>prueba.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); ?> ....................... Pero el contenido en el div se muestra solo desde esta línea: // print_r($_GET); . Necesito mostrar todo el contenido del archivo.
¿Alguien puede ayudarme a arreglar esto? Gracias por adelantado.
Debido a que el analizador HTML de su navegador ve <?php como un elemento HTML, se comentará. Tienes que convertir < y > a sus entidades HTML equivalentes.
Puede hacer esto usando htmlspecialchars (usando <pre></pre> para mantener las nuevas líneas del archivo real):
<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>Puedes ver la salida aquí .