1

How would I go about forcing national letters such as the Danish Æ, Ø and Å letters, in an OOP structure, where the individual .php documents that are concerned with the query and the output, are not under the charset of the HTML doc?

To be more specific I have an index.php file with the following div:

<div id="box_tekst"></div>

I then have the page.js document concerned with handling the asynchronized requests

page.content = function(id) {

    $.ajax({

        url: 'core/page.php',
        type: 'POST',
        data: { method: 'content', id: id },
        success: function(data) {
            $('#box_tekst').html(data);
        }

    });

}

Finally I have the page.php file refered to in the .js document which serves the query in the following maner:

$id = $_POST['id'];
$page = new Page();
$content = $page->getPage($id);

if(!empty($content)) {

    foreach($content as $input) { 
    ?>
        <h1><?= ucfirst($input['title']) ?></h1>
        <p><?= nl2br(ucfirst($input['pg'])) ?></p>
    <?
    }

}
4

1 回答 1

1

Php allows to modify the http response header using the header() function.

header('Content-type: text/html; charset=utf-8');

For exemple the above line sets the response charset to utf-8.

于 2012-12-09T20:15:36.263 回答