|
|
|
La mayoria de las webs de ayuda para webmasters contienen artículos en los cuales expresan un sin fin de códigos para que puedas ocuparlos. Pero la mayoria de estos son monótonos por la forma de representarlos, para no estar en esa lista te enseñaremos la forma de como colorear el código php.
function ColoreaCodigo($texto) { $texto = str_replace(" ", "", $texto); $texto = str_replace(" ", "", $texto); $texto = str_replace(">", ">", $texto); $texto = str_replace("<", "<", $texto); $texto = str_replace("&", "&", $texto); $texto = str_replace(´$´, ´$´, $texto); $texto = str_replace(´n´, ´ ´, $texto); $texto = str_replace(´r´, ´ ´, $texto); $texto = str_replace(´t´, ´ ´, $texto); $texto = str_replace(´"´, ´"´, $texto); $texto = stripslashes($texto); ob_start(); $nivelviejo=error_reporting(0); highlight_string($texto); error_reporting($nivelviejo); $buffer = ob_get_contents(); ob_end_clean(); if ($variable) { $abrirpost = strpos($buffer,´<?´); $cerrarpost = strrpos($buffer, ´?´); $buffer=substr($buffer, 0, $abrirpost).substr($buffer, $abrirpost+5, $cerrarpost-($abrirpost+5)).substr($buffer, $cerrarpost+5); } $buffer=str_replace("","",$buffer); $buffer=str_replace("","",$buffer); return $buffer; } ?>
Con esta funcion basta y sobra. Recuerda que al momento de querer colorear el codigo es importante poner las etiquetas y ?> o si no no te va a funcionar.
|
|