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-size:1.4em\" class=\'string\' ');ΠΠΎΠ²Π΅Π΄Π΅Π½ΠΈΠ΅ ΡΡΠ½ΠΊΡΠΈΠΉ Π·Π°Π²ΠΈΡΠΈΡ ΠΎΡ ΡΡΡΠ°Π½ΠΎΠ²ΠΎΠΊ Π² ΡΠ°ΠΉΠ»Π΅ php.ini.
| ΠΠΌΡ | ΠΠΎ ΡΠΌΠΎΠ»ΡΠ°Π½ΠΈΡ | ΠΠ΅ΡΡΠΎ ΠΈΠ·ΠΌΠ΅Π½Π΅Π½ΠΈΡ | Π‘ΠΏΠΈΡΠΎΠΊ ΠΈΠ·ΠΌΠ΅Π½Π΅Π½ΠΈΠΉ |
|---|---|---|---|
| ignore_user_abort | "0" | INI_ALL |
Β |
| highlight.string | "#DD0000" | INI_ALL |
Β |
| highlight.comment | "#FF8000" | INI_ALL |
Β |
| highlight.keyword | "#007700" | INI_ALL |
Β |
| highlight.default | "#0000BB" | INI_ALL |
Β |
| highlight.html | "#000000" | INI_ALL |
Β |
| browscap | NULL | INI_SYSTEM |
Β |
ΠΡΠ°ΡΠΊΠΎΠ΅ ΡΠ°Π·ΡΡΡΠ½Π΅Π½ΠΈΠ΅ ΠΊΠΎΠ½ΡΠΈΠ³ΡΡΠ°ΡΠΈΠΎΠ½Π½ΡΡ Π΄ΠΈΡΠ΅ΠΊΡΠΈΠ².
ignore_user_abort
bool
false ΠΏΠΎ ΡΠΌΠΎΠ»ΡΠ°Π½ΠΈΡ. ΠΡΠ»ΠΈ ΠΈΠ·ΠΌΠ΅Π½ΡΠ΅ΡΡΡ Π½Π° true, ΡΠΎ ΡΠΊΡΠΈΠΏΡΡ Π½Π΅ Π±ΡΠ΄ΡΡ ΠΏΡΠ΅ΡΠ²Π°Π½Ρ
ΠΏΠΎΡΠ»Π΅ ΡΠΎΠ³ΠΎ, ΠΊΠ°ΠΊ ΠΊΠ»ΠΈΠ΅Π½Ρ ΡΠ°Π·ΠΎΡΠ²ΡΡ ΡΠΎΠ΅Π΄ΠΈΠ½Π΅Π½ΠΈΠ΅.
Π‘ΠΌΠΎΡΡΠΈΡΠ΅ ΡΠ°ΠΊΠΆΠ΅ ignore_user_abort().
highlight.bg
string
highlight.comment
string
highlight.default
string
highlight.html
string
highlight.keyword
string
highlight.string
string
Π¦Π²Π΅ΡΠ° Π΄Π»Ρ ΡΠ΅ΠΆΠΈΠΌΠ° ΠΏΠΎΠ΄ΡΠ²Π΅ΡΠΈΠ²Π°Π½ΠΈΡ (Syntax Highlighting). ΠΡΡ, ΡΡΠΎ ΠΏΡΠΈΠ΅ΠΌΠ»Π΅ΠΌΠΎ Π² <font color="??????">, Π±ΡΠ΄Π΅Ρ ΡΠ°Π±ΠΎΡΠ°ΡΡ.
browscap
string
ΠΠΌΡ (Π½Π°ΠΏΡΠΈΠΌΠ΅Ρ, browscap.ini) ΠΈ ΡΠ°ΡΠΏΠΎΠ»ΠΎΠΆΠ΅Π½ΠΈΠ΅ ΡΠ°ΠΉΠ»Π° Ρ Π°ΡΠ°ΠΊΡΠ΅ΡΠΈΡΡΠΈΠΊ Π±ΡΠ°ΡΠ·Π΅ΡΠ°. Π‘ΠΌΠΎΡΡΠΈΡΠ΅ ΡΠ°ΠΊΠΆΠ΅ ΠΎΠΏΠΈΡΠ°Π½ΠΈΠ΅ ΡΡΠ½ΠΊΡΠΈΠΈ get_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-size:1.4em\" class=\'string\' ');*** Additions to the previous message ***
To change 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 ($functions as $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 functions
foreach ($functions as $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 change 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 ($functions as $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; }