簡體   English   中英

PHP UTF-8編碼

[英]Php UTF-8 encode

我的索引

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?

您可以在此處找到帶有PHP腳本的文檔,以對字符串進行重新編碼。 內容是法語博客文章,但腳本是中間頁中的簡單要點

也許 :

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

在主題上看到使用PHP將HTTP標頭設置為UTF-8

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM