Header() работает после вывода данных. Как такое возможно?

MOHAPX

Новичок
Согласен, с точки зрения логики этот кусок кода не имеет никакого смысла. Им я хотел обратить внимание на то, что не выводится что-то типа Cannot modify header information - headers already sent by ... после
PHP:
echo "test";
. Браузер просто перенаправляет на другую страницу без лишних вопросов...
 

Cid

...двинутый новичок
По теме - проверь настройки output_buffering в php.ini

Цитата из самого ini-файла:

; Output buffering allows you to send header lines (including cookies) even
; after you send body content, at the price of slowing PHP's output layer a
; bit. You can enable output buffering during runtime by calling the output
; buffering functions. You can also enable output buffering for all files by
; setting this directive to On. If you wish to limit the size of the buffer
; to a certain size - you can use a maximum number of bytes instead of 'On', as
; a value for this directive (e.g., output_buffering=4096).
output_buffering = Off
 
Сверху