note 24150 deleted from function.show-source by aidan

From: Date: Sun, 26 Sep 2004 14:11:09 +0000
Subject: note 24150 deleted from function.show-source by aidan
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-77400@lists.php.net to get a copy of this message
Note Submitter: derek at nospam dot mapiq dot com ---- Here is how i add numbers to the show_source.. and also gave a flag for if the user requested no lines to be printed.. This is using PHP4.2.2 <?php if ( !empty ( $_REQUEST['noline'] ) ) { $noline = true; } // Turn on output buffering ob_start(); // Show source of file show_source ( 'mail.php' ); // Get contents of buffer $raw = ob_get_contents(); // Clean and end buffering ob_end_clean(); // Split the source into lines $raw = explode ( '<br />', $raw ); // Insert the line number $ml = strlen ( count ( $raw ) ); for ( $i = 0; $i < count ( $raw ); $i++ ) { if ( !isset ( $noline ) ) { $gap = ( $ml - strlen ( $i ) ); $raw[$i] = "<FONT COLOR=#999999><CODE>[" . str_repeat(" ", $gap ) . $i . "]</CODE></FONT>" . $raw[$i] . "<BR />"; } else { $raw[$i] = "$raw[$i]<BR />"; } } // Convert back to a string $raw = implode ( '', $raw ); // Print source echo "<html>\n <body>\n$raw\n </body>\n</html>"; ?>

« previous php.notes (#77400) next »