SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Mar 2012
    Location
    Lancaster,UK
    Posts
    36
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Question Why does UTF-8 encoding causes certain errors?

    I am reading 'PHP,MySQL Novice to Ninja book by Kevin Yank' and in there he uses a separate file for connecting to the database which I just include into the code when needed which I suppose is a common practice.
    My problem is that when I use UTF-8 encoding for that separate file used to connect to the database, I get errors like that Cannot modify header information - headers already sent by. However, if I change encoding back to ANSI, the problems disappear. How is that possible and what difference does encoding format make anyway?
    Thank you for the answers

  2. #2
    SitePoint Guru bronze trophy
    Join Date
    Dec 2003
    Location
    Poland
    Posts
    930
    Mentioned
    7 Post(s)
    Tagged
    0 Thread(s)
    Most probably your editor adds a BOM to the beginning of the file when you save it as UTF-8. Set your editor to not use BOM and your problem should disappear.

  3. #3
    SitePoint Enthusiast
    Join Date
    Mar 2012
    Location
    Lancaster,UK
    Posts
    36
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Yep, it helped to solve the problem, thanks. Apparently, BOM is just an extra byte sequence at the beginning of the file. I use Notepad++, so UTF-8 with BOM comes as a default. I found out that according to the Unicode standard, the BOM for UTF-8 files is not even commended which begs a question, why such a popular editor such as Notepad++ would leave it like that? I know it's not a big deal or anything but just got me curious.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •