Jump to content

A trick to overcome header errors in utf-8 php file!


webster

Recommended Posts

 

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 ???  :o

 

Regards,

M.Shair

 

 

 

[attachment deleted by admin]

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.