1 Date: Thu, 9 Dec 2010 17:30:39 +0000
2 Mime-Version: 1.0 (Produced by PhpWiki 1.4.0)
3 Content-Type: application/x-phpwiki;
4 pagename=Help%2FPhpHighlightPlugin;
5 flags=PAGE_LOCKED%2CEXTERNAL_PAGE;
8 Content-Transfer-Encoding: binary
10 The **~PhpHighlight** [[Help:WikiPlugin|plugin]] pretty-prints PHP code using the
11 php-function:highlight-string.
15 You specify options for the plugin on the same line as ##~<~<~PhpHighlight##,
16 and put the code on the following lines, until the final ##~>~>##:
19 <<PhpHighlight [wrap?] [color options]
20 code to be highlighted
26 Depending on the ##wrap## option, then the plugin will take care of
27 adding ##<?php## and ##?>## to the code before passing it to
28 php-function:highlight-string. If the PHP delimiters were added, then
29 the plugin removes them again from the highlighted string, before
36 If you don't want the plugin to automatically wrap the source code
37 in ##<?php## and ##?>##, then set ##wrap## to ##0##. The default value is ##1##
38 which means that the plugin takes care of adding and removing
39 ##<?php## and ##?>## automatically.
41 If you set ##wrap## to ##0##, then you'll be able to mix PHP code with
42 HTML. The plugin will then translate '##< ?php##' into '##<?php##' and
43 '##? >##' into '##?>##' to allow you to start and stop PHP mode in your
48 The plugin accepts optional color arguments which correspond to the
49 highlight settings in *php.ini*. Specified colors must be a valid
51 [[http://www.w3.org/TR/REC-html40/types.html#h-6.5|HTML 4 color name]]
52 in lowercase, such as ##'#0f0344'## or ##blue##. You can set the
55 ##string##, ##comment##, ##keyword##, ##bg##, ##default##, and ##html##
59 === PHP with default colors from ##php.ini##: ===
63 echo "Hello World<p>";
67 === HTML with embedded PHP ===
69 Here we have to use ##wrap=0## to prevent automatic wrapping, and escape
70 '##?>##' as '##? >##':
72 <<PhpHighlight wrap=0 html='#000000' bg='#dddddd'
75 <title>PHP Test</title>
78 < ?php echo "<p>Hello World</p>\n"; ? >
85 Although ##highlight_string()## was designed with PHP code in mind it is
86 suitable for basic syntax-highlighting of most C code because the two
89 <<PhpHighlight default=black string=blue comment=gray keyword=purple
95 if ((fp = fopen("/proc/loadavg", "r")) == NULL) {
96 syslog(LOG_ERR, _("%s %s: unable to open %s: %s"), _("FATAL ERROR:"),
97 "getload()", "/proc/loadavg", strerror(errno));
105 * [[mailto:gimpster@gimpster.com|Martin Geisler]]
106 * [[mailto:carstenklapp@users.sourceforge.net|Carsten Klapp]]
109 * [[Help:SyntaxHighlighterPlugin|SyntaxHighlighter]] plugin for highlighting other languages.
113 [[PhpWikiDocumentation]] [[CategoryWikiPlugin]]