douyan8070 2014-04-01 12:47
浏览 49

Php UTF-8编码

My Index

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');
}

My Classes

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();
        }
    }
}

When i show content page mixed characters involved.How can i do utf-8 ?

  • 写回答

2条回答 默认 最新

  • dongnang8192 2014-04-01 12:52
    关注

    You can find a documentation with a PHP script to re-encode your string here. The content is a french blog post but the script is a simple Gist in the middle page

    评论

报告相同问题?

悬赏问题

  • ¥15 任务A:大数据平台搭建(容器环境)怎么做呢?
  • ¥15 r语言神经网络自变量重要性分析
  • ¥15 基于双目测规则物体尺寸
  • ¥15 wegame打不开英雄联盟
  • ¥15 公司的电脑,win10系统自带远程协助,访问家里个人电脑,提示出现内部错误,各种常规的设置都已经尝试,感觉公司对此功能进行了限制(我们是集团公司)
  • ¥15 救!ENVI5.6深度学习初始化模型报错怎么办?
  • ¥30 eclipse开启服务后,网页无法打开
  • ¥30 雷达辐射源信号参考模型
  • ¥15 html+css+js如何实现这样子的效果?
  • ¥15 STM32单片机自主设计