0

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 ?

Baptiste Donaux
  • 1,300
  • 13
  • 34
Cenk
  • 1

2 Answers2

0

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

Baptiste Donaux
  • 1,300
  • 13
  • 34
  • i used for index $encodedArray = array_map(utf8_encode, $content); and for temp utf8_encode($content['con']) but i don't know right ? – Cenk Apr 01 '14 at 13:10
0

Maybe :

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

seen on topic Set HTTP header to UTF-8 using PHP

Community
  • 1
  • 1
Apolo
  • 3,844
  • 1
  • 21
  • 51