Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP closing tag "?>" in cotonti files #1077

Closed
Alex300 opened this issue Nov 7, 2012 · 4 comments
Closed

PHP closing tag "?>" in cotonti files #1077

Alex300 opened this issue Nov 7, 2012 · 4 comments

Comments

@Alex300
Copy link
Member

Alex300 commented Nov 7, 2012

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.

see http://www.php.net/manual/en/language.basic-syntax.phptags.php


К вопросу о лишних пробелах в самом начале выводимой страницы.

Если файл содержит только код PHP, предпочтительно опустить закрывающий тег "?>" в конце файла. Это помогает избежать добавлени случайных символов пробела или перевода строки после закрывающего тега PHP, которые могут послужить причиной нежелательных эффектов, так как PHP начинает выводить данные в буфер при отсутствии намерения у программиста выводить какие-либо данные в этой точке скрипта.

Смотрите:. http://www.php.net/manual/ru/language.basic-syntax.phptags.php

@ghengeveld
Copy link
Contributor

I agree, should be a one-time mass replace.

@trustmaster
Copy link
Member

I used this script to strip closing tags: http://bryan.ravensight.org/2010/07/remove-php-closing-tag/ (requires a *NIX and pcregrep package).

If someone is still in doubt if this was worth it, read this thread: http://stackoverflow.com/questions/4410704/why-would-one-omit-the-close-tag

@trustmaster
Copy link
Member

The previous script fix all endings, this one worked better: http://r15ch13.de/2012/06/delete-all-php-closing-tags-at-the-end-of-all-files/

@macik
Copy link
Member

macik commented Mar 15, 2013

I use this one RegExp: #\?>(?:[\t\r\n\s]*)\Z#

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants