0

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.

1 Answer 1

6

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>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.