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: <?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(); ?> PHP: And here is the class: <?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 PHP: The output in Firefox source view is: <!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 Code (markup): In the Notepad++ is (copied from Firefox): ?<!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 Code (markup): It is a problem while rendering the page (CSS).
You can run a hexdump on the html to determine which ascii character it is trying to output. Then you should at least know what character to look for. Usually, these are characters created from Microsoft or similar products as they don't use the typical hyphen, apostrophe or quote characters. I don't see anything unusual in the content you posted.
I don't see anything either, but I'd change one thing in your script.. You're doing: $homepage -> title="dsf"; PHP: Please change this to: $homepage->title = "dsf"; PHP: (and the same for the other variables) It most likely has nothing to do with your problem, but I thought I'd mention it anyway..
Okay, thanks for it. I found that the problem is related with PHP itself. It does not ignore UTF-8's DOM's (or whaterver they call it) and prints it. PHP6 will have support for UTF-8. I think I can solve this problem by moving the variables' values to a database.
I would have thought saving your files as UTF-8 without BOM would do the trick. I remember I had an endless problem with this BOM-thing when I first tried to put utf-8 characters in my files, I kept getting 'headers already sent' errors - until i found out i shouldn't have saved with BOM. Then it worked fine.