debugging - Reference - What does this error mean in PHP? -


what this?

this number of answers warnings, errors , notices might encounter while programming php , have no clue how fix. community wiki, invited participate in adding , maintaining list.

why this?

questions "headers sent" or "calling member of non-object" pop on stack overflow. root cause of questions same. answers questions typically repeat them , show op line change in his/her particular case. these answers not add value site because apply op's particular code. other users having same error can not read solution out of because localized. sad, because once understood root cause, fixing error trivial. hence, list tries explain solution in general way apply.

what should here?

if question has been marked duplicate of this, please find error message below , apply fix code. answers contain further links investigate in case shouldn't clear general answer alone.

if want contribute, please add "favorite" error message, warning or notice, 1 per answer, short description means (even if highlighting terms manual page), possible solution or debugging approach , listing of existing q&a of value. also, feel free improve existing answers.

the list

also see

warning: cannot modify header information - headers sent

happens when script tries send http header client there output before, resulted in headers sent client.

this e_warning , not stop script.

a typical example template file this:

<html>     <?php session_start(); ?>     <head><title>my page</title> </html> ... 

the session_start() function try send headers session cookie client. php sent headers when wrote <html> element output stream. you'd have move session_start() top.

you can solve going through lines before code triggering warning , check outputs. move header sending code before code.

an overlooked output new lines after php's closing ?>. considered standard practice omit ?> when last thing in file. likewise, common cause warning when opening <?php has empty space, line, or invisible character before it, causing webserver send headers , whitespace/newline when php starts parsing won't able submit header.

if file has more 1 <?php ... ?> code block in it, should not have spaces in between them. (note: might have multiple blocks if had code automatically constructed)

also make sure don't have byte order marks in code, example when encoding of script utf-8 bom.

related questions:


Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -