note 27640 deleted from function.highlight-file by nicos

From: Date: Sun, 15 Dec 2002 10:57:45 +0000
Subject: note 27640 deleted from function.highlight-file by nicos
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-40927@lists.php.net to get a copy of this message
Here is a chunk of code you can put at the top of a file to make it highlight itself (with line numbers). I added the CSS stuff to make the left hand margin a uniform width. <? print "<style>.ln{color:#000000;width:30px;font-size:12px;}</style>\n"; // _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. "; ?> Note that BRs don't display in this forum. The $line variable needs a BR after it when printed. For some reason, the first line of the output doesn't want to obey...

« previous php.notes (#40927) next »