从本地服务器到远程服务器

时间:2016-11-11 21:38:27

标签: php .htaccess utf-8 character-encoding

我有charset的问题 在localhost上一切正常,但现在在远程服务器上我看到奇怪的字符替换其他像à或è。我已经读过它是一个charset问题,我认为问题可能是我的php.ini(我无法编辑)。
为了解决这个问题,我尝试了很多东西:
我已经设置了

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

on html,

ini_set('default_charset', 'UTF-8');

关于php,

AddDefaultCharset utf-8 

在我的.htaccess文件上,
如果我在字符串上使用utf8_encode字母被ã或类似字母替换,如果我离开它而不做任何字母都是
还有另一种方法可以解决我尚未找到的问题吗?

抱歉,我忘了说:通过file_get_contents从我的其他网站检索字符串(我使用的是Yandex API)

以下是一些代码:

$yandex = 'https://dictionary.yandex.net/api/v1/dicservice.json/lookup?key=my_api_key&lang=it-it&text=attualità';

// get json from this page
$object = json_decode(file_get_contents($yandex));
$syns_array = array();
$type = '';
// if the word exists
if (!empty($object->def) && $object->def != FALSE && $object->def != NULL) 
{
    $type = $object->def[0]->tr[0]->pos;
    $rows = $object->def[0]->tr;
    // if there're synonyms
    if (!empty($rows) && $rows != FALSE && $rows != NULL) 
    {
        foreach ($rows as $row) 
        {
            array_push($syns_array, $row->text);
            // if there're more rows with syns
            if (!empty($row->syn) && $row->syn !== FALSE && $row->syn !== NULL) 
            {
                foreach ($row->syn as $syns_obj) 
                {
                    array_push($syns_array, $syns_obj->text);
                }
            }
        }
    }
}

// I echo my synonyms from the array
foreach($syns_array as $syn) {
    echo $syn;
}

1 个答案:

答案 0 :(得分:1)

我忘了说我在那些字符串上使用mb_strtolower。用strotolower取代它问题就解决了......对不起