PHP 8.5.0 Alpha 1 available for testing

Configuración en tiempo de ejecución

El comportamiento de estas funciones se ve afectado por la configuración de php.ini.

Opciones de configuración diversos
Nombre Por defecto Cambiable Historial de cambios
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  
Para más detalles y definiciones de los modos de INI_*, vea Dónde una directiva de configuración puede ser modificada.

He aquí una breve explicación de las directivas de configuración.

ignore_user_abort bool

false por omisión. Si se cambia a true los scripts no se terminarán después de que el cliente anule su conexión.

Ver también ignore_user_abort().

highlight.bg string
highlight.comment string
highlight.default string
highlight.html string
highlight.keyword string
highlight.string string

Colores utilizados para el modo de resaltado sintáctico. Estas opciones pueden tomar cualquier valor válido en <font color="??????">.

browscap string

Nombre del archivo de descripción de clientes HTML. (ej.: browscap.ini) Ver también get_browser().

add a note

User Contributed Notes 3 notes

up
3
Nico
7 years ago
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\' ');
up
-1
Eric
4 years ago
*** 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; }
up
-3
Eric
4 years ago
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; }
To Top