0

マイインデックス

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

関連する文字が混在するコンテンツ ページを表示する場合、どうすれば utf-8 を実行できますか?

4

2 に答える 2

0

多分 :

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

PHP を使用して HTTP ヘッダーを UTF-8 に設定するトピックで見られます

于 2014-04-01T12:53:44.880 に答える
0

文字列を再エンコードするための PHP スクリプトを含むドキュメントは、こちら にあります。内容はフランスのブログ投稿ですが、スクリプトは真ん中のページの簡単な Gist です

于 2014-04-01T12:52:56.870 に答える