PHP的UTF-8编码

问题描述:

我的索引PHP的UTF-8编码

defined("DS") || define("DS", DIRECTORY_SEPARATOR); 
defined("ROOT_PATH") || define("ROOT_PATH", realpath(dirname(__FILE__))); 
require_once(ROOT_PATH.DS.'classes'.DS.'Helper.php'); 

$page = 'default'; 

$uri = $_SERVER['REQUEST_URI']; 

if(!empty($uri)){ 
    $first = substr($uri, 0, 1); 
    if($first == '/') { 
     $uri = substr($uri, 1); 
    } 
    if(!empty($uri)) { 
     $uri = explode('?', $uri); 
     $uri = explode('/', $uri[0]); 
     $page = array_shift($uri); 
    } 
} 

$content = array(
    'con' => Helper::getContent($page) 
); 

if(!empty($_GET['ajax'])) { 
    echo json_encode($content); 
} else { 
    require_once('temp/temp.php'); 
} 

我的课表

class Helper { 

    public static function getContent($file = null) { 
     $file = 'content/'.$file.'.php'; 
     if(is_file($file)) { 
      ob_start(); 
      require_once($file); 
      return ob_get_clean(); 
     } 
    } 
} 

当我告诉页面内容混合字符involved.How我可以做UTF-8?

你可以找到一个PHP脚本的文档来重新编码你的字符串here。内容是法国的博客文章,但剧本是在中间页简单的要点

+0

我用于索引$ encodedArray = array_map(函数utf8_encode,$内容);和临时utf8_encode($ content ['con']),但我不知道对不对? – Cenk

可能:

header('Content-Type: text/html; charset=utf-8'); 

看到题目Set HTTP header to UTF-8 using PHP

+0

不,这是不行的谢谢 – Cenk