Re: Consider only ignoring newlines for final ?> in a file
| From: | Andrea Faulds | Date: | Thu, 07 Sep 2017 14:21:05 +0000 |
| Subject: | Re: Consider only ignoring newlines for final ?> in a file | ||
| References: | 1 2 3 4 5 6 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-100445@lists.php.net to get a copy of this message | ||
Hi,
Christoph M. Becker wrote:
On 07.09.2017 at 15:43, Andrea Faulds wrote:This seems like a reasonable workaround, thank you for the idea. It reminds me of what PHP's source code does with preprocessor instructions: #ifndef FOO # define FOO #endif I might do this in future code. That said, I still think the ?> newline behaviour should be looked at, since this kind of workaround isn't universally applicable (and in any case isn't to everyone's tastes). In particular, if you want to generate plain text and need to insert a newline, having PHP throw them away and requiring you to add extra ones to compensate makes for uglier source code which is harder to reason about. Thanks! -- Andrea Faulds https://ajf.me/Ah. See, it's actually that kind of code that is my problem. A practical example would be: <table>I start the "control flow lines" always on column 0 (similar to C preprocessor instructions), what gives the desired output and is quite readable: <table> <?php foreach($rows as $row): ?><?php foreach($rows as $row): ?> <tr> <?php foreach ($row as $column): ?> <td><?=htmlspecialchars($column)?></td> <?php endforeach; ?> </tr> <?php endforeach; ?></table><tr><?php foreach ($row as $column): ?><td><?=htmlspecialchars($column)?></td><?php endforeach; ?></tr><?php endforeach; ?> </table>