编码问题(php)

vor*_*bey 0 php encoding

我的网站有一个utf-8编码(Drupal).

我使用include函数将我的页面与第三方服务集成.但这会产生一个糟糕的结果 - 包含部分页面的错误编码.

我试试这个,但这不会给出任何结果:

iconv("ASCII","utf-8",include("http://new.velo-travel.ru/themes/themex/spectrum_view.php?$QUERY_STRING"))
Run Code Online (Sandbox Code Playgroud)

在此之前我mb_detect_encoding用来知道编码

这是包含文件:

$url = 'http://young.spectrum.ru/cgi-bin/programs_form.pl';
$params = $_GET;
if ($params){
  $url .= '?';
  foreach ($params as $key => $value) $url .= '&' . $keys . '=' . urlencode($value);
}

#$content = file_get_contents($url);
echo iconv("cp-1251","utf-8", $url);
Run Code Online (Sandbox Code Playgroud)

Luk*_*ský 5

include函数不返回字符串(除非您实际调用return包含的文件),它实际上包含源代码的内容.因此,如果服务器返回PHP源代码,它将在您的服务器上解释(这基本上意味着"new.velo-travel.ru"的所有者可以控制您的站点:)).

此外,正如Augenfeind指出的那样,该页面位于windows-1251中.所以,你可能想要:

echo iconv("windows-1251", "utf-8", file_get_contents("http://new.velo-travel.ru/themes/themex/spectrum_view.php?$QUERY_STRING"))
Run Code Online (Sandbox Code Playgroud)