Reputation: 31
can anybody tell me, how is this possible ? This is my code:
<?php
require_once('class.Widget.php');
try {
$objWidget = new Widget(1);
print "Název nástroje: " . $objWidget->getName() . "<br>\n";
print "Popis nástroje: " . $objWidget->getDescription() . "<br>\n";
$objWidget->setName('2. nástroj');
$objWidget->setDescription('Tohle je druhý nástroj!');
} catch (Exception $e) {
die("Došlo k problému: " . $e->getMessage());
}
?>
I saved it in UTF - 8 encoding, but when I rum it in my web browser (Mozzila Firefox), it looks like this:
Název nástroje: 2. nástroj
Popis nástroje: Tohle je druhý nástroj!
Why are some characters displaying wrong ?
Upvotes: 1
Views: 1699
Reputation: 41
you can try this :
<?php
header('Content-Type: text/html; charset=utf-8');
?>
you should precise it at the beggining of your php script , your browser may decode to your OS default encoding i think
Upvotes: 1
Reputation: 111889
You need to have also:
<meta charset="utf-8" />
in your HTML code
or add this at the beginning of your PHP file:
header('Content-Type: text/html; charset=utf-8');
Upvotes: 4