php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #18554 highlight_string
Submitted: 2002-07-24 21:41 UTC Modified: 2002-07-24 22:50 UTC
From: yann at protonicdesign dot com Assigned:
Status: Wont fix Package: Feature/Change Request
PHP Version: 4.1.2 OS: Linux
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: yann at protonicdesign dot com
New email:
PHP Version: OS:

 

 [2002-07-24 21:41 UTC] yann at protonicdesign dot com
According to me highlight_string should allow you to highlight a string that does not necessairly start with <?php or <?

For the simple reason, that i want to read a file, line by line to return the line number, then the code.

Or there should be a feature in highlight_file so that it returns line numbers.

It is a details but it could be usefull.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-07-24 22:06 UTC] msopacua at idg dot nl
Hi,

highlight_* functions only highlight php code, because php code can be mixed with normal text or HTML.

That said, I like the feature request, like so:
highlight_string(string $source, bool $show_linenumbers)

FYI, it can be done like so:
<?php
ob_start();
highlight_string($source);
$out = ob_get_contents();
ob_end_clean();
$lines = explode("<br />", $out);
for($i=0; $i<count($lines);$i++)
{
    //needs tweaking of the font colors/tags
    printf("%03d: %s<br />", $i+1, $lines[$i]);
}
?>
 [2002-07-24 22:47 UTC] alan at akbkhome dot com
you can also use the tokenizer extension - the code for doing highighlight_string type output can be derived from this.

http://docs.akbkhome.com/akpear/PHP_CodeDoc_Data.html#output_code
 [2002-07-24 22:50 UTC] alan_k@php.net
changing to wont fix - as the ability is already available using the tokenizer.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Dec 26 18:01:31 2024 UTC