雅虎上印刷师的 PHP 引言

发布于 2024-09-19 18:52:50 字数 626 浏览 1 评论 0原文

我的客户是一家小报纸,提供的故事带有印刷者的引语,而不是“直接”引语。这些故事由 PHP 组装成 HTML。在我的 Apache 服务器上,它们显示得很好,但在我的客户站点所在的雅虎上,它们都被问号替换了。

为了解决这个问题,我在 PHP 中编写了以下函数:

function fixquotes($text)
{
    $text = str_replace('’','’',$text);
    $text = str_replace('”','”',$text);
    $text = str_replace('“','“',$text);
    return $text;
};

在上面的函数中,我正在搜索印刷者的引号以将其替换为 HTML 等效项。在我的本地 Apache 服务器上,它运行得很好。在雅虎上,所有拼写错误的引号都会转换为第一个列出的(上图:')。

在我的服务器上,magic-quotes 已关闭,但雅虎已将其打开。我不确定这是否是我的问题的原因,但有可能。

我非常清楚 PHP 中单引号字符串和双引号字符串之间的区别,甚至尝试了上述两种方式,没有任何区别,所以我们不要重耕旧地。

有人有建议的方向供我研究吗?

My client is a small newspaper and provides stories with typographer's quotes instead of "straight" quotes. The stories are assembled into HTML by PHP. On my Apache server, they display fine, but on Yahoo, where my client's site is located, they are all replaced by question marks.

To fix this problem, I wrote the following function in PHP:

function fixquotes($text)
{
    $text = str_replace('’','’',$text);
    $text = str_replace('”','”',$text);
    $text = str_replace('“','“',$text);
    return $text;
};

In the function above, I am searching for typographer's quotes to replace them with HTML equivalents. On my local Apache server, it works great. On Yahoo, all typo-quotes convert to the first listed (above: ’).

On my server, magic-quotes is off, but Yahoo has it turned on. I'm not certain if this is the cause of my problem, but it is possible.

I am quite aware of the difference between single and double quoted strings in PHP, and have even tried the above both ways with no difference, so let's not re-plow old ground.

Does anyone have a suggested direction for me to look into?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

痴情 2024-09-26 18:52:50

这可能是雅虎网络服务器或数据库的字符集问题(如果这些内容存储在数据库中)。

拉出 firebug(或类似的),然后查看开发盒和实时站点上的 HTTP 标头。您可能想使用 php 的 header() 函数强制标头。

It's probably a character-set issue, either in Yahoo's web server, or database if this stuff is stored in a database.

Pull out firebug (or similar), and look at the HTTP headers on your dev box, and the live site. You might want to force a header using php's header() function.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文