utf8 in a class

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
darkhorn
Forum Newbie
Posts: 2
Joined: Thu Sep 03, 2009 3:22 am

utf8 in a class

Post by darkhorn »

I have created a class which is a web page temlate.
All the files are utf-8 encoded.
When I run the page it writes a unseen question mark at the very beggining of the page.
Headers does not help.
What I have to do to remove that question mark?

Here is the main page:

Code: Select all

<?php
header ('Content-type: text/html; charset=utf-8');
require ('template.php');
$homepage = new Page();
$homepage -> title="dsf";
$homepage -> keywords="dsf";
$homepage -> description="dsf";
$homepage -> content="dsf";
 
 
$homepage ->Display();
?>
And here is the class:

Code: Select all

<?php
class Page
{
    public $title;
    public $keywords;
    public $description;
    public $content;
    public $top_menu = array(bla bla bla);
    public $left_menu = array(bla bla bla);
                             
    public function Display()
    {
        $this -> DisplayTypes();
        $this -> DisplayDescription();
        $this -> DisplayKeywords();
                //bla bla bla
        $this -> DisplayFooter();
    }
    
    public function DisplayTypes()
    {
    ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://bla bla bla
The output in Firefox source view is:

Code: Select all

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang bla bla bla
In the Notepad++ is (copied from Firefox):

Code: Select all

?<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang bla bla bla
It is a problem while rendering the page (CSS).
Post Reply