omitting T_CLOSE_TAG

php.internals

Gabor Hojtsy

21 years ago
Hi, I am searching for some evidence in the PHP source code that the possibility of omitting the closing PHP tag is absolutely intentional, and in fact part of the language syntax, and therefore it is going to be supported indefinitely. Digging for T_CLOSE_TAG and similar stuff have lead me to nothing. Actually I would like to clarify and possibly extend the note on page: http://php.net/manual/en/basic-syntax.instruction-separation Also if you have any positive notes on not using the closing tag (or any negative thereof :), please do let me know. Thanks, Goba (PHP Documentation Editor)

George Schlossnagle

21 years ago
On Aug 29, 2005, at 2:38 PM, Gabor Hojtsy wrote:
> Hi, > > I am searching for some evidence in the PHP source code that the > possibility of omitting the closing PHP tag is absolutely intentional, > and in fact part of the language syntax, and therefore it is going > to be > supported indefinitely. Digging for T_CLOSE_TAG and similar stuff have > lead me to nothing. > > Actually I would like to clarify and possibly extend the note on page: > http://php.net/manual/en/basic-syntax.instruction-separation > > Also if you have any positive notes on not using the closing tag > (or any > negative thereof :), please do let me know.
Benefit: No unintentional leakage of whitespace (following a closing ?
>).
George

Gabor Hojtsy

21 years ago
George Schlossnagle wrote:
>> >> Also if you have any positive notes on not using the closing tag (or any >> negative thereof :), please do let me know. > > Benefit: No unintentional leakage of whitespace (following a closing ? >).
Well, the intention of the basic syntax manual page is to point this exact advantage out, but it is probably badly worded :) Goba

Sara Golemon

21 years ago
> I am searching for some evidence in the PHP source code that the > possibility of omitting the closing PHP tag is absolutely intentional, > and in fact part of the language syntax, and therefore it is going to be > supported indefinitely. Digging for T_CLOSE_TAG and similar stuff have > lead me to nothing. >
I can't imagine a situation where that level of BC breakage would *EVER* be permitted. In fact, last I heard it was recommended practice for PEAR files to omit the end tag. I suppose it might accidently break if include were ever shifted to C style inclusion, but that breakage would wind up being considered a bug in the "new feature" and could be easily fixed by automatically reseting the lexer state before and after the include statement.
> Actually I would like to clarify and possibly extend the note on page: > http://php.net/manual/en/basic-syntax.instruction-separation >
An example might be helpful... "<?php echo 'Foo'; ?>" and "<?php echo 'Foo';" are interpreted identically by PHP. -Sara

Andi Gutmans

21 years ago
It is quite intentional and will stick around forever :) Andi At 01:14 PM 8/29/2005, Sara Golemon wrote: