webster Posted August 13, 2008 Share Posted August 13, 2008 Hello, header(); ... header() must be called before any actual output is sent, either by normal HTML tags, blank lines in a file, or from PHP. It is a very common error to read code with include(), or require(), functions, or another file access function, and have spaces or empty lines that are output before header() is called. The same problem exists when using a single PHP/HTML file. <html> <?php /* This will give an error. Note the output * above, which is before the header() call */ header('Location: http://www.example.com/'); ?> or <?php /* This will give an error. Note the output * above, which is before the header() call */ header('Location: http://www.example.com/'); ?> or <?php /* This will give an error. Note the output * above, which is before the header() call */ header('Location: http://www.example.com/'); ?> If you uploaded your php file with above codes you will get a warning: Warning: Cannot modify header information - headers already sent by ... Those are shown errors but what about hidden characters like  that been written using editors if you saved the file with character encoding utf-8. only a none unicode compatible editor (cute html v2.6-2001) will show that marker at the start of the unicode file. There is an edit program (Editpad lite - free from http://www.editpadpro.com/editpadlite.html) has an option to write that marker or not. Click on Options > Configure file types > Encoding Hope that was useful!, I found this trick, is it known to you ??? Regards, M.Shair [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/119530-a-trick-to-overcome-header-errors-in-utf-8-php-file/ Share on other sites More sharing options...
DarkWater Posted August 13, 2008 Share Posted August 13, 2008 Uhh, yeah, okay...it's called the BOM and you can just turn it off in most editors these days, and you can always open a hex editor and remove it rather than download other editors...I guess it'll come in handy for some people though? Quote Link to comment https://forums.phpfreaks.com/topic/119530-a-trick-to-overcome-header-errors-in-utf-8-php-file/#findComment-615781 Share on other sites More sharing options...
budimir Posted August 13, 2008 Share Posted August 13, 2008 Yeah, I know about it. I went nuts with script because of it. It will help some people, defenetly. Every modern editor has a support for enabling/disabling BOM. Quote Link to comment https://forums.phpfreaks.com/topic/119530-a-trick-to-overcome-header-errors-in-utf-8-php-file/#findComment-615906 Share on other sites More sharing options...
webster Posted August 13, 2008 Author Share Posted August 13, 2008 I don't advice to remove that unicode mark unless you need to and it is necessary to add <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> between <head></head> Quote Link to comment https://forums.phpfreaks.com/topic/119530-a-trick-to-overcome-header-errors-in-utf-8-php-file/#findComment-615991 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.