문제

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.

도움이 되었습니까?

해결책

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>
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top