Nikola
Nikola

Reputation: 15038

Store UTF8 text to PHP variable and output it correctly

can you please provide some help, this is my code:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>

<body>
<div id="wrapper">
    <div id="container">
    <?php
            $var = utf8_encode("nađžćča slovaćč");
            echo utf8_decode($var);
        ?>
    </div>    
</div>
</body>
</html>

I did try several things: removing utf8_encode / decode, putting header () in php code, but none of this worked, so can you please tell me where am I doing it wrong, thx!

Upvotes: 2

Views: 5866

Answers (3)

Timur
Timur

Reputation: 6718

You do not need to encode/decode data. Simply, you may save file using UTF-8 encoding.

Upvotes: 3

Dejan Marjanović
Dejan Marjanović

Reputation: 19380

No need to encode or decode data.

Upvotes: 0

Emil Condrea
Emil Condrea

Reputation: 9973

You may get rid of this attribute lang="en". For me , I tried in different browsers and it works well

Upvotes: 1

Related Questions