WordPress Plugin Development – Headers Already Sent Message
My guess is you get a PHP error, which generates output before the headers are sent. If you have E_NOTICE enabled, calling $_POST['foo']
may generate a “Notice: undefined variable” error if that variable is not set.
Best practice: never assume anything about GET, POST, COOKIE and REQUEST variables. Always check first using isset()
or empty()
.
1 2 3 4 | if ( isset( $_POST['foo'] ) ) { $foo = (string) $_POST['foo']; // apply more sanitizations here if needed } |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.