How to fix the "headers already sent" error: omit the closing tag in pure PHP scripts

Опубликовано: 20 Апрель 2018
на канале: Dave Hollingworth
38,910
252

Full PHP course: ➤ https://davehollingworth.net/phpy

It's best practice to omit the PHP closing tag for files that just contain PHP.

This is because it's too easy to insert whitespace after the closing tag. If you're using a function like header, session_start or setcookie, which send HTTP headers, no whitespace can be sent before the headers. If it is, you get the "headers already sent" error.

Resources shown in the video:
http://php.net/manual/en/language.bas...
https://www.php-fig.org/psr/psr-2/
http://php.net/manual/en/outcontrol.c...


Смотрите видео How to fix the "headers already sent" error: omit the closing tag in pure PHP scripts онлайн без регистрации, длительностью часов минут секунд в хорошем качестве. Это видео добавил пользователь Dave Hollingworth 20 Апрель 2018, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 38,910 раз и оно понравилось 252 людям.