On Thu, Sep 7, 2017 at 2:43 PM, Andrea Faulds <[email protected]> wrote:
> Hi Nikita,
>
> Nikita Popov wrote:
>
>>
>> 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.
>>
>>
> I understand that it should be dropped for “control flow” code (maybe not
> the best term, I misunderstood what you meant at first). That's why I
> suggest ignoring the following newline only for the ?> at the end of the
> file, because I can't think of another place where you would have a ?> and
> *not* intend output immediately after it.
>
> So I'm not sure I understand your objection, from that standpoint. Did I
> miss something?
>
> Regards.
>
I'm referring to code like
<ul>
<?php foreach ($data as $value): ?>
<li><?= $value ?></li>
<?php endforeach; ?>
</ul>
Currently this would produce the output
<ul>
<li>Foo</li>
<li>Bar</li>
</ul>
Without the trailing newline elision it would produce
<ul>
<li>Foo</li>
<li>Bar</li>
</ul>
I always assumed that this is the reason why we do this in the first place.
Nikita