Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Read file containing PHP without parsing PHP

I am using a wysiwyg editor in a web app. It is FCKeditor. In order to edit a file, other than loading javascript, my web form that edits the the file looks like this:

<textarea><?php include('myWebDoc.html') ?></textarea>

I also tried this:

<textarea><?php file_get_contents('myWebDoc.html') ?></textarea>

Both attempts end up parsing the php inside the web document before it gets to the editor.

Is there a better php function or way to get the contents of a file into the textarea tag without parsing?

like image 838
H. Ferrence Avatar asked Dec 05 '25 07:12

H. Ferrence


1 Answers

The correct form should be something like this:

<textarea><?php echo htmlspecialchars(file_get_contents('/path/to/file.html')); ?></textarea>

Depending on the contents of the HTML file you might also want to try htmlentities().

like image 82
Alix Axel Avatar answered Dec 07 '25 21:12

Alix Axel



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!