2016-11-02 13 views
1

我有這樣的代碼來顯示txt文件:格式的txt中的file_get_contents PHP

<textarea rows="11" cols="190"> 
<?php 
$file = file_get_contents('./test.txt', FILE_USE_INCLUDE_PATH); 
echo $file; 
?> 
</textarea> 

txt文件是這樣的: enter image description here

在一個乾淨的HTML文件,它看起來像這樣: the format is exactly like the txt file

但是當我用portoadmin模板將它粘貼到laravel中時,txt格式被破壞,它看起來像這樣: the format is broken

這是什麼問題?

在此先感謝

回答

2

更改網頁字體爲等寬型字體,像this。例如,如果你的內心使您的txt文件:

<div id="container"> 
</div> 

然後確保#container元素使用monospace-type字體。例如:

#container { 
    font-family: "Roboto Mono", monospace; 
} 
+0

它的工作,謝謝 –

+0

很高興幫助你,兄弟。 – Alfa