<?php
/*------------------------------*/
/*
Titre : Colorise du code PHP avec validation HTML
Auteur : TommyWeb
Date édition : 03 Mars 2006
Date mise a jour : 14 Aout 2019
Rapport de la maj:
- fonctionnement du code vérifié
- modification de la description
Date mise a jour : 22 Jan 2026
Rapport de la maj:
- fonctionnement du code vérifié en PHP 8
*/
/*------------------------------*/
function colorisationphp($string)
{
$in = array(
'`<(?:font color="|span style="color: )'.
ini_get('highlight.html').'">(.+?)</(?:font|span)>`si',
'`<(?:font color="|span style="color: )'.
ini_get('highlight.comment').'">(.+?)</(?:font|span)>`si',
'`<(?:font color="|span style="color: )'.
ini_get('highlight.default').'">(.+?)</(?:font|span)>`si',
'`<(?:font color="|span style="color: )'.
ini_get('highlight.keyword').'">(.+?)</(?:font|span)>`si',
'`<(?:font color="|span style="color: )'.
ini_get('highlight.string').'">(.+?)</(?:font|span)>`si',
'`</(?:font|span)>`si'
);
$out = array(
'<span style="color: '.
ini_get('highlight.html').'">$1</span>',
'<span style="color: '.
ini_get('highlight.comment').'">$1</span>',
'<span style="color: '.
ini_get('highlight.default').'">$1</span>',
'<span style="color: '.
ini_get('highlight.keyword').'">$1</span>',
'<span style="color: '.
ini_get('highlight.string').'">$1</span>',
'</span>'
);
}
?>
KOogar
18 Mars 2007 à 16:37Comme n'importe quel autre fonction :
echo colorisationphp($string);
Dothazard
18 Mars 2007 à 13:30Comment l'utiliser?