Chinese characters showing incorrectly in html page

时间:2015-05-08 10:02:41

标签: html

Hi I started in creating an html page with Chinese characters.

I used W3 schools try it page as a reference to what i am doing, I simply put the code in their try it window and see my output.

The thing is that i used this code

$entries = array();
if($data && is_array($data['feed']['entry']))
                               {
                                       foreach($data['feed']['entry'] as $vid)
                                       {
                                               $vid = $vid['media$group'];
                                               $url = $vid['media$content'][0]['url'];
                                               $url = substr($url, 0, stripos($url, '?'));
                                               $entries[] = array(
                                                               'id' => $vid['yt$videoid']['$t'],
                                                               'url' => $url,
                                                               'title' => $vid['media$title']['$t'],
                                                               'date' => $vid['yt$uploaded']['$t'],
                                                               'content' => $vid['media$description']['$t']
                                                       );
                                       }
                               }
$entries = array();
                               if($data && is_array($data['items']))
                               {
                                       foreach($data['items'] as $vid)
                                       {
                                       //var_dump($data['items']);
                                               $vid = $vid['snippet'];
                                               $url = "https://www.youtube.com/watch?v="+$vid['resourceId']['videoId'];
                                               //$url = substr($url, 0, stripos($url, '?'));
                                               $entries[] = array(
                                                               'id' => $vid['resourceId']['videoId'],
                                                               'url' => $url,
                                                               'title' => $vid['title'],
                                                               'date' => $vid['publishedAt'],
                                                               'content' => $vid['description']
                                                       );
                                       }
                               }

But no matter what i give in font family, the chinese characters are not showing in the output page

Somebody please help only 'hhh' is coming, chinese characters are showing as '?'..

Edit to add is that the code is working fine in firefox browser, but not working in chrome, why? because the code has to be independent of browser right?

1 个答案:

答案 0 :(得分:2)

You're missing the <!doctype html> <html> <?php define( 'ROOT_DIR', dirname(__FILE__) ); include( ROOT_DIR.'/inc/head.php' ); // include 'inc/head.php'; // include '../app/views/inc/head.php'; ?> tag. Try using <?php $pageTitle = "login-register | Twitter"; define( 'ROOT_DIR', dirname(__FILE__) ); include( ROOT_DIR.'/inc/header.php' ); // include '../app/views/inc/header.php'; ?> in your head.

meta