Search code examples
phptagsreadfileplaintext

Read .php file without applying HTML and PHP tags in the result


I need to read a .php file as plain text.

Text in main script:

<?php $data = file_get_contents('file2read.php'); ?> <pre> <?php echo $data; > </pre>

For example, I have this in file2read.php:

<tr>
  <td><?php> e(enlace('/pages/index', __('index'), True, False, array('class' => 'ajax'))); ?></td>
</tr>

The output of the main script is:

'ajax'))); ?>

I want that output to be something like this in plain text:

<tr>
  <td><?php> e(enlace('/pages/index', __('index'), True, False, array('class' => 'ajax'))); ?></td>
</tr>

Solution

  • Done using htmlentities()

    <?php echo htmlentities($data); ?>