• Home
  • Services
  • Profile
  • Portfolio
  • Contact
  • Links
  • Blog
  • Archives
  • Sitemap
Subscribe: Posts | Comments | E-mail
  • Ajax XMLHttpRequestAsynchronous HTTP Request How To's
  • FreebiesBest Freebies Collection
  • MiscellaneousNews, Announcements & General Stuffs
  • Print & Web DesignPhotoshop, Vector, CSS, XHTML
  • ProgrammingProgramming PHP, ASP, .NET and more

Bali Web Design

Posted on August 16, 2008 - by webmaster

Is there a secret behind file encoding in PHP?

Miscellaneous

Today i faced a strange warning message when executing a PHP file,

Warning: session_start() [function.session-start]:
		 Cannot send session cache limiter - headers already sent
		 (output started at file.php:1) in
		 file.php on line 15

Well not the error message, but the reason that produce this message, i have tried to use different solutions to avoid this error:

  • Put the session_start() command in the very first line
  • Explicit set of session_save_path
  • Change the permission (CHMOD 777)
  • Reset the php.ini session auto start + Explicit set on the codes

but none of ‘em fix the error. Then i try to use unusual test, changing the file encoding from UTF-8 (i always save my file in UTF-8 encoding) to ANSI, and Booom! the error message gone :) .

Didnt really know how the file encoding can cause this error, because i always use UTF-8 and produce the same code and never get this error. Is there any secret of file encoding on PHP?, now you tell me :) , because within ANSI i could not produce foregin characters, so i need a better solutions, to kiss this error away and keep the UTF-8 encoding.

Any suggestions guys?

Share this article:
  • Digg
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • LinkedIn
  • MySpace
  • Ping.fm
  • Pownce
  • Slashdot
  • StumbleUpon
  • Technorati
  • Tumblr
  • TwitThis
This entry was posted on Saturday, August 16th, 2008 at 10:26 and is filed under Miscellaneous. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

5 Comments

We'd love to hear yours!



  1. Visit My Website

    August 16, 2008

    Permalink

    aceman3000 said:

    Maybe you saved the UTF-8 file with BOM (Byte Order Mark). This adds a byte in the beginning of the file and could produce the error you reported.



  2. Visit My Website

    August 30, 2008

    Permalink

    johni said:

    Not only maybe. I’m shure this was the Problem. I had the same Problem when i was about to switch to UTF-8. No i’m using Notepad++ which supports UTF-8 files without BOM.



  3. Visit My Website

    September 1, 2008

    Permalink

    demonita said:

    me either using notepad++, but sometimes using Dreamweaver or PHP designer, still could not find the cause, cos the other files works just fine.



  4. Visit My Website

    October 17, 2008

    Permalink

    ari said:

    Notepad++ version 4 had a bug with encoding and BOM, get Notepad++ 5 and save it without BOM from there.



  5. Visit My Website

    June 19, 2009

    Permalink

    phpman said:

    Well, it’s a little too late but this error has nothing to do with encoding. The error “headers already sent” pops when you try to send some metainfo in the header of the page, but the header has already been sent.

    You must control the header sending manually. at the begin of you PHP just put, the first instruction of all:
    <? ob_start();

    And then at the end, or when you want to send the headers, put "ob_end_flush();"

    This way you control when to "release" the page to the client.



Leave a Comment

Here's your chance to speak.

  1. Name (required)

    Mail (required)

    Website

    Message

  • Most Popular Posts

    • { 108 } ResponsesPHP ajax login form using Jquery
    • { 79 } Responsesphp ajax tutorial create ajax based login form using jquery
    • { 71 } ResponsesASP Classic Programming Still Alive
    • { 53 } Responses63+ best practice to optimize PHP code performances
    • { 44 } ResponsesVideobox: Lightbox for videos
  • Latest Posts

    • PHP Newbie: Proper handling of Error & Exception in PHP
    • Why SEO lost importance
    • jQuery Mobile Announced : Touch-Optimized Web Framework for Smartphones & Tablets
    • Multiple Google Account Signin
    • Install, Configure & Running Memcache in Windows as Service
    • DynamicWP Image Cube Wordpress Plugin
    • New Wordpress 3.0 API menu_page_url
    • Wordpress 3.0 Custom Taxonomy
    • JQuery DataGrid Plugin Compass
    • Upgrading to upcoming CodeIgniter 2.0
  • Categories

    • advertorial
    • Ajax XMLHttpRequest
    • Featured
    • Freebies
    • Miscellaneous
    • Print & Web Design
    • Programming
    • Tutorials
    • Web 2.0
  • Featured News

    • PHP Newbie: Proper handling of Error & Exception in PHP by webmaster on August 18, 2010
    • Why SEO lost importance by webmaster on August 16, 2010
    • jQuery Mobile Announced : Touch-Optimized Web Framework for Smartphones & Tablets by webmaster on August 16, 2010
    • Install, Configure & Running Memcache in Windows as Service by webmaster on June 27, 2010
    • Website Optimization Best Practices, speed up your website load by ruby on May 21, 2009
  • Tag Cloud

    • Actionscript advertorial Ajax XMLHttpRequest API best practices CakePHP chat Classic ASP CMS CSS Development facebook firefox Flash flickr Freebies gmail HTML icons Javascript Jobs jQuery jQuery Plugins Library Lightbox memcache Mootools news Personal PHP PHP Frameworks plurk Print & Web Design prism Prototype regex regular expression Scriptaculous SEO Tutorial twitter Web 2.0 Wordpress Works YUI
  • Archives

    • August 2010
    • June 2010
    • May 2010
    • September 2009
    • June 2009
    • May 2009
    • April 2009
    • March 2009
    • February 2009
    • January 2009
    • December 2008
    • November 2008
    • October 2008
    • September 2008
    • August 2008
    • July 2008
    • June 2008
    • May 2008
    • April 2008
    • March 2008
    • February 2008
    • January 2008
    • December 2007
    • November 2007
    • October 2007
copyleft 2007 - 2010 Bali Website Design Studio