note 110843 added to function.highlight-file
| From: | System32 | Date: | Thu, 13 Dec 2012 20:24:46 +0000 |
| Subject: | note 110843 added to function.highlight-file | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-192520@lists.php.net to get a copy of this message | ||
My custom function for displaying lines:
function highlight_linesfile($filename, $return = false) {
if(file_exists($filename) && is_file($filename)) {
$output = '<pre><code><span style="color:
'.ini_get('highlight.html').';">';
$code = substr(highlight_file($filename, true), 36, -15); //Thanks to this post: http://php.net/manual/en/function.highlight-file.php#92160
$start_line = 1;
$lines = explode('<br />', $code);
$chr_lines = count($lines);
$chr_lines = strlen($chr_lines);
foreach($lines as $line)
{
$nline = str_pad($start_line, $chr_lines, ' ', STR_PAD_LEFT);
$output .= '<span style="color: grey;"
class="php_highlight_line">'.$nline. ':</span> '.$line;
$start_line ++;
}
$output .= '</span></code></pre>';
if($return === true) return $return;
else echo $output;
}
}
use this to disable selection of lines:
.php_highlight_line {
-moz-user-select: -moz-none;
-khtml-user-select: none;
-webkit-user-select: none;
-ms-user-select: none;
user-select: none;
}
----
Server IP: 69.147.83.199
Probable Submitter: 78.0.147.149
----
Manual Page -- http://php.net/manual/en/function.highlight-file.php
Edit -- https://master.php.net/note/edit/110843
Del: integrated -- https://master.php.net/note/delete/110843/integrated
Del: useless -- https://master.php.net/note/delete/110843/useless
Del: bad code -- https://master.php.net/note/delete/110843/bad+code
Del: spam -- https://master.php.net/note/delete/110843/spam
Del: non-english -- https://master.php.net/note/delete/110843/non-english
Del: in docs -- https://master.php.net/note/delete/110843/in+docs
Del: other reasons-- https://master.php.net/note/delete/110843
Reject -- https://master.php.net/note/reject/110843
Search -- https://master.php.net/manage/user-notes.php