如何使用<pre> tag to don&#39;t appear in the source code

时间:2015-09-29 00:37:17

标签: php pre

I would like to render a webpage like the pastebin.com does in a raw view mode. Here is an example on pastebin.com

http://pastebin.com/raw.php?i=VawEm8ge

if you look to the source code, there is no html code.

I tried in this way:

   <pre style="word-wrap: break-word; white-space: pre-wrap;">
   #EXTM3U
   #EXTVLCOPT:udp-caching=1000
   #EXTINF:-1, DUNA Televízió
   http://212.40.98.166/intstreams/mtva/dunalive.smil/VID_854x480_HUN.m3u8

   #EXTINF:-1 , Duna World
   http://212.40.98.161/intstreams/mtva/dunaworldlive_international.smil/VID_854x480_HUN.m3u8
  </pre>

But the output is not the same with the output from the pastebin.com

1 个答案:

答案 0 :(得分:1)

It is because that page is not HTML. If you take a look at the response, the Content-Type is text/plain; charset=utf-8.

To do the same thing on your sever, you need to control the response header to set Content-Type. For example:

header('Content-Type: text/plain');

Just set it before writing output.