Req #23253 [Opn->Ver]: highlight_string($string) removes newlines from input string
| From: | yohgaki@php.net | Date: | Wed, 31 Jul 2013 05:56:13 +0000 |
| Subject: | Req #23253 [Opn->Ver]: highlight_string($string) removes newlines from input string | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-180615@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=23253&edit=1
ID: 23253
Updated by: yohgaki@php.net
Reported by: gk at proliberty dot com
Summary: highlight_string($string) removes newlines from
input string
-Status: Open
+Status: Verified
Type: Feature/Change Request
-Package: Feature/Change Request
+Package: *General Issues
-Operating System: linux
+Operating System: *
-PHP Version: 4.3.2RC1
+PHP Version: master
Block user comment: N
Private report: N
New Comment:
Current PHP doesn't add linefeed as reporter said. However, we do not have to
change behavior as highlighted source is for browsers, not human.
Left this report open, in case someone would like to change behavior.
Previous Comments:
------------------------------------------------------------------------
[2003-04-17 02:06:09] gk at proliberty dot com
If you use highlight_string() to produce HTML formatted source, the output string replaces newlines
with <br \>.
This is very ugly and unnecessary.
Whitespace is an important part of code; readability is not an insignificant feature.
Instead, "\n" should be replaced with "<br \>\n", or
"<br>\n", to be HTML compliant.
<?php
// $source_file includes line breaks
$source=join('',file($source_file));
$body=highlight_string ( $source, $return=TRUE);
// $body is a single line, without line breaks
?>
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=23253&edit=1