highlight_string

(PHP 4 , PHP 5)

highlight_string -- Applique la syntaxe colorisée à du code PHP

Description

mixed highlight_string ( string str [, bool return] )

highlight_string() affiche la version colorisée du code PHP contenu dans le paramètre str, en utilisant les couleurs du système interne de colorisation de PHP.

Si le second paramètre optionnel return est fourni, et vaut TRUE alors highlight_string() retournera la chaîne colorisée au lieu de l'afficher immédiatement. Si le second paramètre ne vaut pas TRUE alors highlight_string() retournera TRUE en cas de succès, et FALSE sinon.

Exemple 1. Exemple avec highlight_string()

<?php
highlight_string
('<?php phpinfo(); ?>');
?>

Cette exemple affichera (en PHP 4):

<code><font color="#000000">
<font color="#0000BB">&lt;?php phpinfo</font><font color="#007700">(); </font><font color="#0000BB">?&gt;</font>
</font>
</code>

Cette exemple affichera (en PHP 5):

<code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php phpinfo</span><span style="color: #007700">(); </span><span style="color: #0000BB">?&gt;</span>
</span>
</code>

Note : Le paramètre return est disponible depuis PHP 4.2.0. Auparavant, il prenait la valeur par défaut de FALSE

Voir aussi highlight_file() et show_source().