簡體   English   中英

如何將php和html文件的內容顯示到textarea中?

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM