Vous êtes ici Codes PHP et MySQL > Chaînes > Colorisation de code php valide xhtml

 

Colorisation de code php valide xhtml

Ceci est un morceau de code qui va rendre un code php en couleur et tout cela valide en xhtml !
 
TommyWeb
[2] sources en PHP voir
Vu 5564 fois
Enregistré le 03 Mars 2006
  • Digg ce code sur digg.com
  • Bookmark ce code sur del.icio.us
  • Bookmark ce code sur Google
  • Bookmark ce code sur Yahoo
  • Ajoute Colorisation de code php valide xhtml
  • Partage ce code sur Facebook
 
 
 
 

Code Source


01.
02.
03.
04.
05.
06.
07.
08.
09.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
 
<?php
/******************************************************************************/
/*                                                                            */
/*                       __        ____                                       */
/*                 ___  / /  ___  / __/__  __ _____________ ___               */
/*                / _ \/ _ \/ _ \_\ \/ _ \/ // / __/ __/ -_|_-<               */
/*               / .__/_//_/ .__/___/\___/\_,_/_/  \__/\__/___/               */
/*              /_/       /_/                                                 */
/*                                                                            */
/*                                                                            */
/******************************************************************************/
/*                                                                            */
/* Titre          : Colorisation de code php valide xhtml                     */
/*                                                                            */
/* URL            : http://www.phpsources.org/scripts165-PHP.htm              */
/* Auteur         : TommyWeb                                                  */
/* Date édition   : 03 Mars 2006                                              */
/*                                                                            */
/******************************************************************************/

function colorisationphp($string)
{
    $string highlight_string($stringtrue);
                
    $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);
}
?> 
 

Fonctions du code source

: Applique la syntaxe colorisée à du code PHP - (PHP 4, PHP 5)
: Crée un tableau - (PHP 4, PHP 5)
: Lit la valeur d'une option de configuration - (PHP 4, PHP 5)
: Rechercher et remplacer par expression rationnelle standard - (PHP 4, PHP 5)
Commentaires
Comment l'utiliser?
 
Comme n'importe quel autre fonction :

echo colorisationphp($string);
 
Ajouter un commentaire
Code de sécurité

Attention: Les champs marqués d'une étoile * sont obligatoires
 
 
 On Focus
Dev référencement Visiter Dev3w qui est un outil de référencement de sites.

Référencement gratuit
 

Connexion

 
 
  Annonce Google
 

Chaînes

 
 

PHP