Note: You are viewing an old revision of this page. View the current version.
The PhpHighlightPlugin pretty-prints PHP code using the php-function:highlight-string.
You specify options for the plugin on the same line as the <?plugin, and put the code on the following lines, until the final ?>:
<?plugin PhpHighlight [wrap?] [color options] code to be highlighted ?>
Depending on the =wrap= option, then the plugin will take care of adding =<?php= and =?>= to the code before passing it to php-function:highlight-string. If the PHP delimiters were added, then the plugin removes them again from the highlighted string, before presenting it.
Automatic Wrapping:
If you don't want the plugin to automatically wrap the source code in <?php= and ?>, then set wrap= to 0. The default value is 1= which means that the plugin takes care of adding and removing <?php= and ?>= automatically. If you set wrap= to 0, then you'll be able to mix PHP code with HTML. The plugin will then translate '=< ?php' into '=<?php' and '? >' into '?>' to allow you to start and stop PHP mode in your code.
Color Options:
The plugin accepts optional color arguments which correspond to the highlight settings in php.ini. Specified colors must be a valid hexadecimal color or HTML 4 color name in lowercase, such as ='#0f0344'= or blue. You can set the following options: string, comment, keyword, bg, default, and =html=
function hello() {
<pre>
echo "Hello World<p>";
</pre>
}
Here we have to use wrap=0= to prevent automatic wrapping, and escape '?>=' as '? >':
<html>
<pre>
<head>
<title>PHP Test</title>
</head>
<body>
<?php echo "<p>Hello World</p>\n"; ?>
</body>
</pre>
</html>
Although =highlight_string()= was designed with PHP code in mind it is suitable for basic syntax-highlighting of most C code because the two syntax are similar.
# include <stdio.h>
/~* Get load */
int
getload(void)
{
<pre>
if ((fp = fopen("/proc/loadavg", "r")) =~= NULL) {
syslog(LOG_ERR, _("%s %s: unable to open %s: %s"), _("FATAL ERROR:"),
"getload()", "/proc/loadavg", strerror(errno));
exit(EX_OSFILE);
}
fclose(fp);
</pre>
}
Martin Geisler and Carsten Klapp .
http://www.okuno.com.cn/ http://www.carcenter.com.cn/ http://www.xiangde.com.cn/ http://www.j-net.com.cn/ http://www.chinabm.net.cn/ http://www.lead-int.com/ http://www.paiwei.cn/ http://www.sunflow.com.cn/ http://www.txhf8.com/ http://www.lyzhuguang.com/ http://www.emicn.com/
http://www.carcenter.com.cn/add/ http://www.chinabm.net.cn/add/ http://www.lead-int.com/add/ http://www.amwaypower.com/amwaypower/ http://www.amwaypower.com/amway_china/ http://www.amwaypower.com/amway_gongsi/ http://www.amwaypower.com/amway_chanpin/ http://www.amwaypower.com/amway_niucuilai/ http://www.amwaypower.com/amway_usa/ http://www.amwaypower.com/amway_zhixiao/ http://www.paiwei.cn/add/ http://www.playseo.com/bjlvyou/ http://www.playseo.com/zuche021/ http://www.playseo.com/zuche8/ http://www.playseo.com/zuche/ http://www.saishuo.com/tiezhixiangji/ http://www.sunflow.com.cn/sunflow/ http://www.txhf8.com/add/
http://qichezulin.51.net/ http://guanlipeixun.51.net/ http://diandu123.51.net/ http://usauniversity.51.net/ http://pagerank.51.net/ http://amwaypower.51.net/ http://amwaypower.51.net/amway_china/ http://amwaypower.51.net/amway_gongsi/ http://amwaypower.51.net/amway_chanpin/ http://amwaypower.51.net/ay_niucuilai/ http://amwaypower.51.net/amway_usa/ http://amwaypower.51.net/amway_zhixiao/ http://fadianjizu.51.net/ http://bjlvyou.51.net/ http://zuche021.51.net/ http://zuche8.51.net/ http://tiezhixiangji.51.net/ http://sunflow.51.net/ http://zhibanji.51.net/ http://siweiyuan15.51.net/ http://siweiyuan14.51.net/ http://siweiyuan13.51.net/ http://siweiyuan12.51.net/ http://siweiyuan11.51.net/ http://siweiyuan10.51.net/ http://siweiyuan09.51.net/ http://siweiyuan08.51.net/ http://siweiyuan07.51.net/ http://siweiyuan06.51.net/ http://siweiyuan05.51.net/ http://siweiyuan04.51.net/ http://siweiyuan03.51.net/ http://siweiyuan02.51.net/ http://siweiyuan01.51.net/ http://siweiyuan.51.net/
http://www.playseo.com/somewebpage.htm http://www.souwho.com/somewebpage.htm http://pagerank.51.net/somewebpage.htm http://www.amwaypower.com/keywords/free1.htm http://www.boshilw.com/keywords/free1.htm http://www.carcenter.com.cn/free1.htm http://www.dfhb.com/keywords/free1.htm http://www.dxslw.com/keywords/free1.htm http://www.emicn.com/keywords/free1.htm http://www.gfqy.com/keywords/free1.htm http://www.google123.net/keywords/free1.htm http://www.google123.org/keywords/free1.htm http://www.j-net.com.cn/free1.htm http://www.lnhbsb.com/keywords/free1.htm http://www.ly-yufeng.com/keywords/free1.htm http://www.lyzhuguang.com/keywords/free1.htm http://www.lxep.com/keywords/free1.htm http://www.newstyle-w.com/keywords/free1.htm http://www.okuno.com.cn/free1.htm http://www.paiwei.cn/keywords/free1.htm http://www.playseo.com/keywords/free1.htm http://www.saishuo.com/keywords/free1.htm http://www.sh-xinping.com/keywords/free1.htm http://www.shhcy.com/keywords/free1.htm http://www.songshangroup.com/free1.htm http://www.souwho.com/keywords/free1.htm http://www.sunflow.com.cn/keywords/free1.htm http://www.suntront.com.cn/keywords/free1.htm http://www.think-t.com/keywords/free1.htm http://www.txhf8.com/keywords/free1.htm http://www.vita-biotech.com/keywords/free1.htm http://www.writerlw.com/keywords/free1.htm http://www.xiangde.com.cn/free1.htm http://www.xinpushihua.com/keywords/free1.htm http://www.xtzn.com/keywords/free1.htm http://www.ycc-zipper.com.cn/keywords/free1.htm http://pagerank.51.net/free1.htm http://siweiyuan.51.net/free1.htm http://usauniversity.51.net/free1.htm
Sponsored by: Labrat Technology -- Need Consulting Services? Programming, Maintenance, Security, Database Analysis & Design, Hosting -- we do it all!
Copyright 2005 Robert Melton
Send questions and comments to
Last updated March 10th, 2005