本地win7 把数组写入 txt 文本日志 json_encode转换中文,需要加上JSON_UNESCAPED_UNICODE 不适用unicode --仅仅支持php5.4以后

json_encode 改进 为 json_encode_ex


function json_encode_ex($value)
{
  if (version_compare(PHP_VERSION, '5.4.0', '<')){

  $str = json_encode($value);
  $str = preg_replace_callback("#\u([0-9a-f]{4})#i", function ($matchs) {
  return iconv('UCS-2BE', 'UTF-8', pack('H4', $matchs[1]));
  }, $str);
  return $str;
  } else {
  return json_encode($value, JSON_UNESCAPED_UNICODE);
  }
}


function mylog1($word){
  if(YII_DEBUG){
  $file = 'mylog1.txt';
  file_put_contents($file,'执行时间'.date('Y-m-d H:i:s',time())." ".$word." ",FILE_APPEND);
  }
}

原文地址:https://www.cnblogs.com/bj-tony/p/6101048.html