Output code as text in php

后端 未结 1 1226
醉梦人生
醉梦人生 2021-01-28 17:00

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 reg

1条回答
  •  旧巷少年郎
    2021-01-28 17:22

    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

     and 
    tags before and after the string

    0 讨论(0)
提交回复
热议问题