dongzhan1492 2011-12-28 05:14
浏览 13
已采纳

输出代码作为php中的文本

Basically, I want to to something similar as to what mybb does in php, where they will output code between [code][/code] tags as highlighted text. Obviously I will need some regular expressions, but what's the key to outputting all php code as plain text, especially after stored in a db.

Edit: not just php code but all code as plain text

  • 写回答

1条回答 默认 最新

  • douweng1904 2011-12-28 05:19
    关注

    IMO, the easiest way would be to:

    1) Read your text into a string

    2) Optionally, run htmlspecialchars()

    3a) echo() the string

    3b) be sure to add <pre> and </pre> tags before and after the string

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

报告相同问题?

悬赏问题

  • ¥15 微信会员卡等级和折扣规则
  • ¥15 微信公众平台自制会员卡可以通过收款码收款码收款进行自动积分吗
  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目
  • ¥20 mysql架构,按照姓名分表
  • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分