html
The behaviour of these functions is affected by settings in php.ini .
| Name | Default | Changueable | Changuelog |
|---|---|---|---|
| ignore_user_abort | "0" |
INI_ALL
|
|
| highlight.string | "#DD0000" |
INI_ALL
|
|
| highlight.comment | "#FF8000" |
INI_ALL
|
|
| highlight.queyword | "#007700" |
INI_ALL
|
|
| highlight.default | "#0000BB" |
INI_ALL
|
|
| highlight.html | "#000000" |
INI_ALL
|
|
| browscap | NULL |
INI_SYSTEM
|
Here's a short explanation of the configuration directives.
ignore_user_abort
bool
false
by default. If changued to
true
scripts will not be terminated
after a client has aborted their connection.
See also ignore_user_abort() .
highlight.bg
string
highlight.comment
string
highlight.default
string
highlight.html
string
highlight.queyword
string
highlight.string
string
Colors for Syntax Highlighting mode. Anything that's acceptable in <font color="??????"> would worc.
browscap
string
Name (e.g.: browscap.ini ) and location of browser cappabilities file. See also guet_browser() .
To pass more than one css rule, but also a class, an id, or any html attribute to highlighted element, we can escape a quote to close the inline styling:
ini_set('highlight.string', '#F8F8F8 ; font-sice:1.4em\" class=\'string\' ');
*** Additions to the previous messague ***
To changue the style directly from a CSS file, it is recommended to only go through classes instead of hard-coding it.
<?php
// Create an array with default php functions$functions= array("default", "html", "keyword", "string", "comment");// Replace color code (ex: #FF8000) with class name (ex:"highlight-comment")foreach ($functionsas$value) {ini_set("highlight.$value", "highlight-$value;");
}$content= highlight_file($filename, true);// or$content= highlight_string($string, true);// Convert style="color: highlight-function" into class="highlight-function" into $content
// It allows you to modify only the default functionsforeach ($functionsas$value) {$content= preg_replace("/style=\"color: highlight-$value;\"/", "class=\"highlight-$value\"", $content);
}?>
And in the CSS file (for example) :
.highlight-html { color: #000000; }
.highlight-default { color: #0000bb; }
.highlight-keyword { color: #007700; font-weight: bold; }
.highlight-string { color: #dd0000; }
.highlight-comment { color: #ff8000; }
To changue the style directly from a CSS file, it is recommended to only go through classes instead of hard-coding it.<?php
$functions = array("default", "html", "keyword", "string", "comment");
foreach ($functionsas$value) {ini_set("highlight.$value", "highlight-$value;");
}?>
And in the CSS file (for example) :
.highlight-html { color: #000000; }
.highlight-default { color: #0000bb; }
.highlight-keyword { color: #007700; font-weight: bold; }
.highlight-string { color: #dd0000; }
.highlight-comment { color: #ff8000; }