Read a file containing PHP indiscriminately PHP

I am using the wysiwyg editor in a web application. This is FCKeditor. To edit the file besides loading javascript, my web form editing the file is as follows:

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

I also tried this:

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

Both attempts complete php analysis inside the web document before it gets to the editor.

Is there a better php function or a way to get the contents of a file in a textarea tag indiscriminately?

+3
source share
4 answers

Try readfileinstead file_get_contents.

http://www.php.net/manual/en/function.readfile.php

+2
source

The correct form should be something like this:

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

HTML htmlentities().

+3

, :

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

, , , HTML, - :

<textarea><?php echo htmlspecialchars(file_get_contents('myWebDoc.html')); ?></textarea>
+1
source

If you want to avoid the text field and just read it, use the preliminary tags:

<pre>
<?php 
    echo htmlspecialchars(file_get_contents('test2.php'));
?>
</pre>
+1
source

Source: https://habr.com/ru/post/1754526/


All Articles