php高亮显示php文件 ,并显示行号
kevin.Zhu 发布于:2013-1-16 15:30 分类:Php 有 11 人浏览,获得评论 0 条
function highlight_with_linenum($file)
{
//open handle, set vars
$handle = fopen($file, "r");
$count = 1;
$lines = "";
//look line ends
while ($thisone = fread($handle, "1"))
{
if ($thisone == "\n")
{
//add number
$lines .= $count . "<br />";
$count++;
}
}
//close handle
fclose($handle);
//highlight contents
$contents = highlight_file($file, TRUE);
//print output (you could as well return now)
print '<table><tr><td><code>' .
$lines . '</code></td><td>' .
$contents . '</td></tr></table>';
}
http://blog.csdn.net/dizzthxl/article/details/7841701