dongxixian7803 2015-09-29 00:37
浏览 173
已采纳

如何使用<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条回答 默认 最新

  • douchuifk90315 2015-09-29 00:40
    关注

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
  • ¥50 成都蓉城足球俱乐部小程序抢票
  • ¥15 yolov7训练自己的数据集
  • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)
  • ¥15 电力市场出清matlab yalmip kkt 双层优化问题
  • ¥30 ros小车路径规划实现不了,如何解决?(操作系统-ubuntu)