![](/img/trans.png)
[英]How to save the content of a textarea into a html file in PHP or JS
[英]How to display content of a php and html file into a textarea?
我正在嘗試將包含php代碼和html代碼的文件的內容顯示到文本區域中。 我做了
<textarea name='codemodifier' cols='110' rows='35' id='codemodifier' class='form-control' style='height: 75vh;'><?php echo file_get_contents("myfile.php"); ?></textarea>
但是,它不顯示僅文件內容,而是在文本區域下顯示其他html代碼。
我編輯了代碼並做了
<textarea name='codemodifier' cols='110' rows='35' id='codemodifier'
class='form-control' style='height: 75vh;'><?php echo
htmlspecialchars(file_get_contents("myfile.php")); ?></textarea>
然后,文本區域中不再顯示任何內容。 當我使用htmlentites而不是htmlspecialchars時,出現相同的問題。
如何將php和html文件的內容顯示到textarea中?
這些看起來像UTF-8字符,請在將文件內容輸出到textarea之前嘗試使用utf_decode()
對其進行解碼。
此函數將字符串數據從UTF-8編碼轉換為ISO-8859-1。 字符串中無效的UTF-8字節和ISO-8859-1中不存在的UTF-8字符(即U + 00FF以上的字符)將替換為?。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.