Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP closing tag unnecessary? [duplicate]

Tags:

php

tags

Possible Duplicate:
why in some scripts they omit the closing php tag ?>

As explained in the Code Igniter style guide, it seems that PHP closing tags are optional. It even say you should avoid it for several reasons.

Anyone would have some more information about this issue ?

Thanks !

like image 918
Boris Delormas Avatar asked Jul 27 '10 14:07

Boris Delormas


People also ask

Is it necessary to close PHP tag?

If a file contains only PHP code, it is preferable to omit the PHP closing tag at the end of the file.

What is <? PHP tag?

php and ?>. These are called PHP's opening and closing tags. Statements witihn these two are interpreted by the parser. PHP script within these tags can be embedded in HTML document, so that embedded code is executed on server, leaving rest of the document to be processed by client browser's HTML parser.

How do you end a PHP statement?

Note: PHP statements end with a semicolon ( ; ).


1 Answers

One reason people avoid the closing ?> tag is avoid "the headers already sent error" due to line breaks or other invisible characters after the ?> tag.

like image 182
GWW Avatar answered Oct 12 '22 12:10

GWW