Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:100436 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 31391 invoked from network); 7 Sep 2017 10:19:27 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 7 Sep 2017 10:19:27 -0000 Authentication-Results: pb1.pair.com smtp.mail=nikita.ppv@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=nikita.ppv@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.214.49 as permitted sender) X-PHP-List-Original-Sender: nikita.ppv@gmail.com X-Host-Fingerprint: 209.85.214.49 mail-it0-f49.google.com Received: from [209.85.214.49] ([209.85.214.49:37527] helo=mail-it0-f49.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 49/BE-10715-F2D11B95 for ; Thu, 07 Sep 2017 06:19:27 -0400 Received: by mail-it0-f49.google.com with SMTP id o200so392564itg.0 for ; Thu, 07 Sep 2017 03:19:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=5dnhqQA+m+410QThAPra2mMRds0NHFGzsR1l2cLD9yg=; b=qoNcFz3FxXzHxuxGcgABQ0aHWWXhZiuR/4HUL9qRCzDBCgDKSPYpV0fG2JHMM7Nj// +l8oEaNpWTINKd+lr4kvvTGyMpswV4Se7mOqpBccxwh02xkcUUKNCebgMaLjO8ibCgIE 0/YB4U5NsB2WyvcTHTM+OEw3O61YrGS36fLqTJ43Wp3iw7q7p+nEJUsIimxOAlwhq2ne eaTU2az0YIXW/nRTuOBfSpbWgcB1UnlExWdNug8NocaiX8SprVwMNlbn/dzyctk5uIsc 3REkY4mCOLyJSC9M7RR6G2ThKGhT5r67XnNHFuMYdV1Z8k7Jnrpv6AfKTSYRW8PUzgGY FsjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=5dnhqQA+m+410QThAPra2mMRds0NHFGzsR1l2cLD9yg=; b=Osgvy8rCrAJqoctg+Hu18D+eBcEtO+OCZT3+i7LfcFM8dsuGrweto2CnWnVklbrPHI /BhNJfhoWCyBKneUVOFtPxiGiBj3/vLXRQ63ttxj2+KRfNrZhmIV80LV8P9SJuhriZDp EnZWy2SWjJLpjo35O9ws+WK11l9CsG0fjOiJDF2b171l9Vs/pFI0iLtC8/rGX/2K30mG PrIdzXOh0LBQlB7MDJCgjD0BO45lKurkVV6GYD9EkzWqaVY5X1Y9yFt9/Krq3wy6WhCG MDhCs53Q5mFtcVN2ojxYrD/R2nx7EtI50LJ2F6sloBZ+zGTF5J/8qU/RZCVj+zPg/fN1 HB8g== X-Gm-Message-State: AHPjjUjK6e3Bchs+vuieg7y2QUDh3Q8r7GYNEZilOq4satEQuFm7axnb XcN26m9R1Y7+lbRntjfWsOKY/qaP6w== X-Google-Smtp-Source: AOwi7QATei4YReIHUNux+k3fzRvJUbuwNX9nL07LRHg96+IWlmkTbmrZBUhj7b8j9aBsMiTr2BetaLjnJiPKIfObVGs= X-Received: by 10.36.112.69 with SMTP id f66mr174896itc.64.1504779564498; Thu, 07 Sep 2017 03:19:24 -0700 (PDT) MIME-Version: 1.0 Received: by 10.107.13.3 with HTTP; Thu, 7 Sep 2017 03:19:23 -0700 (PDT) In-Reply-To: <8C.6B.10715.4A4A0B95@pb1.pair.com> References: <8C.6B.10715.4A4A0B95@pb1.pair.com> Date: Thu, 7 Sep 2017 12:19:23 +0200 Message-ID: To: Andrea Faulds Cc: PHP internals Content-Type: multipart/alternative; boundary="001a1144d5f66844a8055896cbad" Subject: Re: [PHP-DEV] Consider only ignoring newlines for final ?> in a file From: nikita.ppv@gmail.com (Nikita Popov) --001a1144d5f66844a8055896cbad Content-Type: text/plain; charset="UTF-8" On Thu, Sep 7, 2017 at 3:45 AM, Andrea Faulds wrote: > 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: > > > >
foo bar
> > 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! > It also goes the other way. Whether you want to drop the newline after ?> depends (roughly) on whether the code is control flow (drop) or trailing output (don't drop). If the newline is not dropped anymore it doesn't mean that the output will look nice, it's just going to be broken in a different way. Nikita --001a1144d5f66844a8055896cbad--