this snippet highlights a php file and numberes the lines.
show php code
in a nice layout.
“simple php code highlight” makes use of the built-in PHP functions
file( ),
count( ) and
highlight_file( ).
01 <?php
02
03 // specify the file to highlight
04 $file_to_highlight = __file__;
05
06 echo '
07 <table style="border: 0; spacing: 0; margin: 0; width: 600px;">
08 <tr>
09 <td style="width: 20px;
10 background-color: #D4D4D4;
11 padding-right: 2px;
12 padding-left: 2px;
13 text-align: right;
14 vertical-align: top;">
15 <pre style="margin: 0; padding: 0;">';
16
17 $temp = file($file_to_highlight);
18 for($i = 1; $i <= count($temp); $i++)
19 {
20 echo $i.'
21 ';
22 }
23
24 echo '
25 </pre>
26 </td>
27 <td style="width: 580px;
28 background-color: #FFFFFF;
29 padding-right: 5px;
30 padding-left: 5px;
31 vertical-align: top;">';
32
33 highlight_file($file_to_highlight);
34
35 echo '
36 </td>
37 </tr>
38 </table>
39 ';
40
41 ?>