Search code examples
phpcoding-style

Why do some scripts omit the closing PHP tag, '?>'?


In some scripts I see that they omit writing a closing tag ?> for the script. Why is it and should I do this as well?

(I'm sure they have not forgotten it.)


Solution

  • Well, omitting the closing tag is just one solution for avoiding blanks and other characters at the end of file. For example any char which is accidentally added behind the closing tag would trigger an error when trying to modify header info later.

    Removing the closing tag is kind of "good practice" referring to many coding guidelines.