Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/281.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 从strftime对字符串进行编码_Php_String_Date_Strftime - Fatal编程技术网

Php 从strftime对字符串进行编码

Php 从strftime对字符串进行编码,php,string,date,strftime,Php,String,Date,Strftime,我有以下代码: strftime("%A %d %B %Y" ,strtotime($res['date'])) 它打印的是:luned� 2014年5月15日 但它可以打印:lunedì15 settembre 2014我在首页上设置了UTF8字符,我尝试: str_replace("ì" , "ì" , strftime("%A %d %B %Y" ,strtotime($res['date']))); 但它不起作用,我怎样才能替换� 到ì 我已经用utf8\U解码解决

我有以下代码:

strftime("%A %d %B %Y" ,strtotime($res['date']))
它打印的是:luned� 2014年5月15日

但它可以打印:lunedì15 settembre 2014我在首页上设置了UTF8字符,我尝试:

str_replace("ì" , "ì" , strftime("%A %d %B %Y" ,strtotime($res['date'])));
但它不起作用,我怎样才能替换� 到ì


我已经用utf8\U解码解决了它,在我替换了它之后?对于ì

这是一个编码问题,您可能需要对结果进行utf8_解码

试试这个:

$var = strftime("%A %d %B %Y" ,strtotime($res['date']));
$var = utf8_decode($var);
echo $var; // If there is any special character it will be well printed for example
           //  ì 

您是否为html页面使用了正确的编码

在我的浏览器test.php上的HTML5上运行良好

<html>
<head>
</head>
<body>
<?php
setlocale(LC_ALL, 'it_IT');
echo  strftime("%A %d %B %Y" ,strtotime());   
?>
</body>
</html>


输出:giovedì01 gennaio 1970

是否打印?相反,在我的电脑上,它工作得很好。当您回显$var时,它现在打印什么?这是输出:luned?15 SettMBRE 2014我已经解决了它,在我使用utf8\U解码后我替换了它?使用ì,因为使用“day”时,唯一的特殊var是添加的示例,因此如果使用