enconding issue

2019-01-25 10:34发布

I'm developing a website using PHP and these strange chars "" appears in my page, right on the top of it. My code is this:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><?php echo '';?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

But when I see the source code in the browser, it shows this:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

I don't know if has any relation to the encoding I'm using, because when I change the charset to charset=utf-8 it disappears but I must use iso-8859-1

4条回答
虎瘦雄心在
2楼-- · 2019-01-25 11:15

simple solution, just placed your html/php code is start from first line, I am just do that to resolve these problem, and it's work.

查看更多
做个烂人
3楼-- · 2019-01-25 11:16

Look at the "Page Info" screen and see what character set the browser thinks you're in. The odds are that your web server is forcing UTF-8 with its Content-Type header, which trumps the meta tag.

查看更多
相关推荐>>
4楼-- · 2019-01-25 11:19

If you want to use iso-8859-1, you need to save your PHP file as iso-8859-1.
For detailed instructions, please tell us which editor you're using.

However, I highly recommend that you use UTF8 instead.

查看更多
做个烂人
5楼-- · 2019-01-25 11:38

That's a BOM character, which is there because the source code files are saved as UTF-8 BOM. Try to save them as UTF-8 no-BOM (or whatever your editor calls it) or indeed ISO-8859-1 if you must use it (...why would you?).

查看更多
登录 后发表回答