简体   繁体   中英

php non-english character using $echo

in Php, I want to print Düsseldorf using

 echo 'Düsseldorf'; 

However it turns out to be something like this D�sseldorf

Please suggest what should I do to print european characters mostly non-english.

The PHP, File and HTML encoding should be the same.

For PHP:

<?php header('Content-Type: text/html; charset=utf-8'); ?>

Check the encoding of your text editor.

For HTML:

<meta charset=utf-8>

The quick and dirty way:

echo 'D&uuml;sseldorf ist eine sch&oouml;ne Stadt!';
// Düsseldorf ist eine schöne Stadt!

If you are able to specify it as a constant, do the following.

$echo 'D&#252;sseldorf';

For further information refer to the chart here: http://www.ascii.cl/htmlcodes.htm

Every character that's printable has a corresponding HTML entity.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM