Doc #76316 [Opn->Nab]: fail to print newline after end tag in included file

From: Date: Wed, 09 May 2018 12:37:41 +0000
Subject: Doc #76316 [Opn->Nab]: fail to print newline after end tag in included file
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-15675@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=76316&edit=1

 ID:                 76316
 Updated by:         requinix@php.net
 Reported by:        divinity76 at gmail dot com
 Summary:            fail to print newline after end tag in included file
-Status:             Open
+Status:             Not a bug
 Type:               Documentation Problem
 Package:            Unknown/Other Function
 Operating System:   linux, debian 10 x64 k4.16.5-1
 PHP Version:        7.2.5
 Block user comment: N
 Private report:     N

 New Comment:

The next page says
> ...when the PHP interpreter hits the ?> closing tags, it simply starts outputting whatever
> it finds (except for an
> immediately following newline - see instruction separation)...
http://php.net/manual/en/language.basic-syntax.phpmode.php

And the page after that, which it linked to,
> The closing tag for the block will include the immediately trailing newline if one is present.
http://php.net/manual/en/language.basic-syntax.instruction-separation.php


Previous Comments:
------------------------------------------------------------------------
[2018-05-09 10:15:41] divinity76 at gmail dot com

Description:
------------
reading the docs at http://php.net/manual/en/language.basic-syntax.phptags.php
, >>>everything outside of a pair of opening and closing tags is ignored by the PHP parser.
<<< everything outside of the closing tag should be ignored by the parser, and just
printed, and further >>>If a file is pure PHP code, it is preferable to omit the PHP
closing tag at the end of the file. This prevents accidental whitespace or new lines being added
after the PHP closing tag, which may cause unwanted effects because PHP will start output buffering
when there is no intention from the programmer to send any output at that point in the
script.<<<

here it's at least heavily implied that newlines after the end tag will be printed, but this is
not actually the case. newlines after the end tags seems to be not printed, almost as if it was part
of the end tag.

Test script:
---------------
<?php
$tmp=tmpfile();
fwrite($tmp,"<?php ?>\n");
ob_start();
require(stream_get_meta_data($tmp)['uri']);
var_dump(bin2hex(ob_get_clean()));

Expected result:
----------------
string(2) "0a"

Actual result:
--------------
string(0) ""


------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=76316&edit=1


Thread (2 messages)

« previous php.doc.bugs (#15675) next »