Using some borrowed code from www.php.net, I came up with this chunk of
code that can be included at the top of a PHP script to make it
highlight itself in a web browser. However, the first opening PHP tag in
the output has a space or two in front of it. Does anyone know why?

<?
   print "<style>.ln{color:#000000;width:40px;font:normal 10px
courier;}</style>"; // _ignore_
   $contents = highlight_file(basename($_SERVER['PHP_SELF']), true); //
_ignore_
   $contents = explode("<br />", $contents); // _ignore_
   $ln = 1; // _ignore_
   foreach($contents as $line) if(!strstr($line, "_ignore_")) { print
"<span class=ln>$ln:</span>$line<br>"; $ln++; } // _ignore_
   exit; // _ignore_
   print "Hello, cruel world. ";
   while(true)
      print "God I love PHP. ";
?>

Reply via email to