i want to echo $html variable (which contents html code of page) to browser in my php script. but if my $html has cyrillic symbol echo is breaking on it symbol - all before this symbol is on page - but all next is empty, what reason can it be?
+1
A:
The character encoding of the value of $html
does not suit the character encoding you declare your output with. You need to identify the character encoding of $html
and make sure to properly declare your output to be encoded with it.
The best way to do that is the HTTP header. You can do that with header
:
header('Content-Type: text/html;charset=utf-8');
This declares the content to be HTML encoded with UTF-8.
Besides that, PHP and the web server have default character encodings that are sent if no other was specified. In PHP, the default character encoding is specified by default_charset; and as for Apache web server, it is specified by AddDefaultCharset
.
Gumbo
2010-09-08 12:09:41