<?php
|
/*---------------------------------------------------------------*/
|
/*
|
Titre : Colorise du code PHP avec validation HTML
|
|
URL : https://phpsources.net/code_s.php?id=165
|
Auteur : TommyWeb
|
Date édition : 03 Mars 2006
|
Date mise à jour : 14 Aout 2019
|
Rapport de la maj:
|
- fonctionnement du code vérifié
|
- modification de la description
|
*/
|
/*---------------------------------------------------------------*/
|
|
function colorisationphp($string)
|
{
|
$string = highlight_string($string, true);
|
|
$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>'
|
);
|
|
return preg_replace($in, $out, $string);
|
}
|
?>
|
|
|
KOogar
18 Mars 2007 à 16:37Comme n'importe quel autre fonction :
echo colorisationphp($string);
Dothazard
18 Mars 2007 à 13:30Comment l'utiliser?