简体   繁体   English

HTML / PHP编码,特殊字符可在一台服务器上工作,而不能在另一台服务器上工作

[英]HTML/PHP encoding, special characters work on one server for not another

I'm having problems understanding why one server running PHP/Apache is formatting special characters properly and another one isn't. 我在理解为什么一台运行PHP / Apache的服务器正确格式化特殊字符而另一台没有格式化字符时遇到问题。

the meta tag i am using is; 我正在使用的元标记是;

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

I have also tried; 我也尝试过;

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

the server that is correctly is running; 正确运行的服务器;

Apache/2.4.9 (Win64) PHP/5.5.11 Apache / 2.4.9(Win64)PHP / 5.5.11

the one that is incorrectly formatting, and replacing characters with a black diamond with a question mark inside it, is running; 格式不正确的字符正在运行,并且用黑色菱形替换其中带有问号的字符,该字符正在运行;

Apache/2.4.10 (Win32) OpenSSL/1.0.1i PHP/5.6.3 Apache / 2.4.10(Win32)OpenSSL / 1.0.1i PHP / 5.6.3

I'm assuming its a config issue, Where? 我假设它是配置问题,在哪里? I don't know. 我不知道。 Perhaps its a difference in default behavior. 也许这与默认行为有所不同。 it cant be the code because it is identical on both servers. 它不能是代码,因为两个服务器上的代码相同。

The HTML meta tag only has secondary significance for signalling the encoding; HTML元标记仅对发出编码信号具有次要含义; the HTTP Content-Type header takes precedence if present. HTTP Content-Type标头 (如果存在)优先。 One server is setting that header, the other isn't (or is setting the wrong one). 一台服务器正在设置该标头,而另一台则没有(或者设置了错误的一个)。

Either set your default charset appropriately in Apache, or explicitly output that header yourself in PHP: 在Apache中适当地设置默认字符集,或者在PHP中自己显式输出该标头:

header('Content-Type: text/html; charset=iso-8859-1');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM