0

(Sorry my English isn't very good) Hello I have problem with UTF-8. When i'm trying to convert file to UTF-8(when i use session_start() ) I'm always getting warning Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at...)

and sessions is not works because output starting on UTF-8. I'm from Lithuania and I need Lithuanian letters (ą,č,ę,ė,į,š,ų,ū,ž) and with other codings (UTF-8 without BOM, ANSI and others) i can't write any LT letters (becouse letters will changing to (ąęėąĨė90čįūė0Ĩ-Å«9Ĩę0ųį0) ). But only with UTF-8 without BOM sessions works. So my question: how to use LT letters on UTF-8 without BOM or how to use sessions on UTF-8?

Chris Kdon
  • 916
  • 1
  • 14
  • 26
  • You can try this then. Start a PHP start/end tag with just `` then open a new one with the rest of your code `` it could work. Also, adding `ob_start();` above `session_start();` is also an option. – Funk Forty Niner Jun 10 '14 at 16:26
  • im using that my code front: ` Naujas Wapas be pavadinimo – user3726786 Jun 10 '14 at 16:30

2 Answers2

0

You probably use somewhere in your code session_cache_limiter function. And in documentation there's info you need to use it before session_start and not after.

EDIT

If I simple use your code:

<?php ob_start(); 
session_start(); ?> 
<HTML> <HEAD> <LINK href="stilius.css" rel="stylesheet" type="text/css">
 <title>Naujas Wapas be pavadinimo</title> </HEAD> <BODY> 
 <?php 
 echo "test";

no warning is displayed so something wrong must be in other parts of your code. What happens when you launch the above code? Are there any errors or warnings?

Marcin Nabiałek
  • 109,655
  • 42
  • 258
  • 291
  • nope. `Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent line 4` line 4 is session_start() `` can you help me to fix it? – user3726786 Jun 10 '14 at 16:40
  • if UFT-8 without BOM it works, but with UFT 8 i getting warning ` Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/errqraz/domains/errqraz.us.lt/public_html/wap/1test.php:1) in /home/errqraz/domains/errqraz.us.lt/public_html/wap/1test.php on line 2` – user3726786 Jun 11 '14 at 09:12
0

If you save your file as UTF-8 with BOM, that's something the browser can recognise the encoding on. But a BOM is not the only way to signal that the content is UTF-8 encoded, and is in fact one of the worse methods. You should be setting a Content-Type HTTP header and a <meta> HTML element, both of which declare the document to be encoded in UTF-8 accordingly. Then you can save your document without BOM and there will be no output before any PHP code, eliminating any problems.

See:

Community
  • 1
  • 1
deceze
  • 510,633
  • 85
  • 743
  • 889
  • If most (all?) browsers see the BOM (Byte Order Mark) in the PHP file, outside the PHP code block, they will treat it as displayable content and flush all the headers, which prevents you from sending more headers. Make sure **none** of your files have a BOM saved with them. Then make sure you're not overlooking any error messages displayed to the screen. Does session_start() produce any error messages? – Phil Perry Jun 10 '14 at 18:38
  • @Phil Browsers have nothing to do whatsoever with BOMs flushing the headers. That's all server-side. – deceze Jun 10 '14 at 18:57
  • Ah, true. My bad. I should have said the _server_ will flush all content, including the headers, _to_ the browser when it sees the first content (non-header) material, which includes any BOM. – Phil Perry Jun 10 '14 at 19:02