Using some borrowed code from, 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); //
   $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. ";
      print "God I love PHP. ";

Reply via email to