highlight_string() 函数对字符串进行语法高亮显示。
</>code
- highlight_string(string,return)
参数 | 描述 |
---|---|
string | 必需。要进行高亮处理的字符串。 |
return | 可选。如果设置 true,则本函数返回高亮处理的代码。 |
本函数通过使用 PHP 语法高亮程序中定义的颜色,输出或返回给定的 PHP 代码的语法高亮版本。
如果 return 参数被设置为 true,那么该函数会以字符串返回被高亮处理的代码,而不是输出它们。否则,若成功,则返回 true,失败则返回 false。
</>code
- <html>
- <body>
- <?php
- highlight_string("Hello world! <?php phpinfo(); ?>");
- ?>
- </body>
- </html>
输出:
</>code
- Hello world! <?php phpinfo();?>
在浏览器中查看的结果类似这样:
</>code
- <html>
- <body>
- <code>
- <span style="color: #000000">Hello world!
- <span style="color: #0000BB"><?php phpinfo</span>
- <span style="color: #007700">();</span>
- <span style="color: #0000BB">?></span>
- </span>
- </code>
- </body>
- </html>
如对本文有疑问,请提交到交流论坛,广大热心网友会为你解答!! 点击进入论坛
Powered by 365建站网 RSS地图 HTML地图
copyright © 2013-2024 版权所有 鄂ICP备17013400号