doulue1949 2014-01-03 22:52
浏览 46
已采纳

使用PHP生成iMacro语法 - <SP> Spaces

I need to generate imacro syntax for the user to be able to copy from the browser screen.

Since iMacro is using <SP> for spaces I need to replace database values that have spaces with with <SP>.

This isn't working because the browser recognizes <SP> as HTML character.

$srtnew = str_replace(" ","<SP>",$string);

Any suggestions?

  • 写回答

2条回答 默认 最新

  • dongrongdao8902 2014-01-03 22:54
    关注

    You need to do:

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

    before you output it.

    This tells the browser to output the content as a pure text format and not as html.

    Of course you could also do it like this:

    $srtnew = str_replace(" ",htmlentities("<SP>"),$string);
    

    If you have many tags you should just set the header if you only want to output that code in order to let your users copy them.

    More information about setting headers in PHP: http://www.php.net/manual/de/function.header.php

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 obsidian的中文层级自动编号
  • ¥15 同一个网口一个电脑连接有网,另一个电脑连接没网
  • ¥15 神经网络模型一直不能上GPU
  • ¥15 pyqt怎么把滑块和输入框相互绑定,求解决!
  • ¥20 wpf datagrid单元闪烁效果失灵
  • ¥15 券商软件上市公司信息获取问题
  • ¥100 ensp启动设备蓝屏,代码clock_watchdog_timeout
  • ¥15 Android studio AVD启动不了
  • ¥15 陆空双模式无人机怎么做
  • ¥15 想咨询点问题,与算法转换,负荷预测,数字孪生有关