Diego
Diego

Reputation: 17

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>

Upvotes: 0

Views: 590

Answers (2)

Diego
Diego

Reputation: 17

Done using htmlentities()

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

Upvotes: 0

Marsel Arduanov
Marsel Arduanov

Reputation: 170

Read as plain text

$data = file_get_contents('file2read.php');

Output to a web page in plain text

<pre>
   <?php echo $data; ?>
<pre>

Upvotes: 2

Related Questions