php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #45455 highlight_file could take start/length line numbers for excerpts
Submitted: 2008-07-08 13:45 UTC Modified: 2008-07-08 14:44 UTC
From: ceo at l-i-e dot com Assigned:
Status: Not a bug Package: Feature/Change Request
PHP Version: 5.2.6 OS: N/A
Private report: No CVE-ID: None
 [2008-07-08 13:45 UTC] ceo at l-i-e dot com
Description:
------------
I would find highlight_file much more useful, particularly for writing on-line tutorials, articles, etc if it would take a line number and count optional arguments, to print out only an excerpt of the file.

One could then intersperse bits of code and commentary very easily with original source files instead of having to keep code snippets in sync as you develop/author an article.

One can, of course, play games with explode("<br />" and array_slice, but it's a bit of a pain, really.

It would also be extra nifty if line numbers could be added on the left with yet another optional arg, and maybe even an arg for absolute|relative numbering for the snippets.

PHP Rocks!



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-07-08 14:44 UTC] johannes@php.net
highlight_file is a small helper and not meant to be a full-features highlighter.

Instead of parsing the output you might also read the file (using file(), file_Get_contents() or so and then use highlight_string() on some chunks of it.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun Jul 27 20:00:02 2025 UTC