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

From: Date: Tue, 24 Dec 2013 20:37:18 +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-183459@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: So at the least this warrants a documentation update right? Previous Comments: ------------------------------------------------------------------------ [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 (#183459) next »