Req #23253 [Com]: highlight_string($string) removes newlines from input string

From: Date: Tue, 24 Dec 2013 21:19:59 +0000
Subject: Req #23253 [Com]: highlight_string($string) removes newlines from input string
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-183460@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 Comment by: aaron dot hamid at gmail dot com Reported by: gk at proliberty dot com Summary: highlight_string($string) removes newlines from input string Status: Verified Type: Feature/Change Request Package: *General Issues Operating System: * PHP Version: master Block user comment: N Private report: N New Comment: I submitted the attached patch to php doc system for review. How would one go about introducing a minor enhancement as described - just a pull request? The change is trivial and I don't think it would have any BC implications. Previous Comments: ------------------------------------------------------------------------ [2013-12-24 20:37:18] aaron dot hamid at gmail dot com So at the least this warrants a documentation update right? ------------------------------------------------------------------------ [2013-07-31 05:56:12] yohgaki@php.net 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. ------------------------------------------------------------------------ [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

« previous php.bugs (#183460) next »