Pergunta

I want to display html file content in php file script without execute any php script from html file. It's for security reason.

Files :  
|_ content 
| |_page.html 
|_page.php

page.php content :

<div>
    <span>
     <?php include('content/page.html'); ?>
    </span>
</div>

page.html content :

    <b>Titre :</b> hello world. 
<?php echo "[php execution]"; ?>

When I open the page.html I see:

Titre : hello world.

when I open the page.php I see:

Titre : hello world.[php execution]

I don't want to execute any php script on the page.html because the user can change the content. I would like to include only the html content and disable all php script execution.

Foi útil?

Solução

include will always exclude PHP code, but you can get round this by reading and echoing the file instead:

<div>
  <span>
    <?php echo file_get_contents('content/page.html'); ?>
  </span>
</div>
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top