Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:100435 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 29697 invoked from network); 7 Sep 2017 10:12:02 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 7 Sep 2017 10:12:02 -0000 Authentication-Results: pb1.pair.com header.from=francois@tekwire.net; sender-id=softfail Authentication-Results: pb1.pair.com smtp.mail=francois@tekwire.net; spf=softfail; sender-id=softfail Received-SPF: softfail (pb1.pair.com: domain tekwire.net does not designate 212.27.42.4 as permitted sender) X-PHP-List-Original-Sender: francois@tekwire.net X-Host-Fingerprint: 212.27.42.4 smtp4-g21.free.fr Received: from [212.27.42.4] ([212.27.42.4:56777] helo=smtp4-g21.free.fr) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id FA/5E-10715-17B11B95 for ; Thu, 07 Sep 2017 06:12:02 -0400 Received: from [172.16.0.25] (unknown [158.255.108.131]) (Authenticated sender: flaupretre@free.fr) by smtp4-g21.free.fr (Postfix) with ESMTPSA id C364619F5A1; Thu, 7 Sep 2017 12:11:55 +0200 (CEST) To: Andrea Faulds , internals@lists.php.net References: <8C.6B.10715.4A4A0B95@pb1.pair.com> Message-ID: <6dd0d2d1-3a4b-5b42-8396-0a6456a97f11@tekwire.net> Date: Thu, 7 Sep 2017 12:11:53 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: <8C.6B.10715.4A4A0B95@pb1.pair.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: fr Subject: Re: [PHP-DEV] Consider only ignoring newlines for final ?> in a file From: francois@tekwire.net (=?UTF-8?Q?Fran=c3=a7ois_Laupretre?=) Hi Andrea, Le 07/09/2017 à 03:45, Andrea Faulds a écrit : > Hi everyone, > > This is the tiniest of issues, but it's bugged me for a long time and > makes the HTML produced by PHP code less readable than it out to be. > Specifically, PHP ignores a newline immediately following a ?> tag. > The reason for this is, from what I recall, to prevent issues where > whitespace at the end of a PHP file is echoed before headers can be > sent. On UNIX in particular, all text files (should) end in a newline, > so this is a reasonable and necessary feature. > > However, for ?> tags anywhere that aren't right at the end of the > file, this is just a nuisance that makes for messy output. For > example, HTML output that should look like: > > >     >        >        >     >
foobar
> > May instead end up looking something like: > >     >               >    
foobar
> > Of course, HTML doesn't matter so much, it'll render the same to the > end-user. However, for outputting e.g. plain text, newlines can be > significant, and so you have to insert an ugly and surprising extra > newline following a tag. > > Would anyone object to me changing how PHP handles this so that only > the final ?> tag consumes its following newline, and only at the end > of the file? > > Thanks! +1 to create a PHP8 branch and change the behavior there. not in PHP7. Once again, some may think it's too early but, IMO, we should create such a branch and encourage RFCs and changes targeting next major version to be announced, discussed, implemented, and tested as soon as possible. This is the only way to introduce BC breaks while minimizing their impact. We saw this when talking about PHP7 features : when proposed too late, changes introducing BC breaks generally must be rejected, whatever their value. Regards François