wampserver - Alter language settings for PHP application - WAMP server -
alter language settings php application - wamp server. firefox not regognize language in php-application , replace letters in language small <?>-icons
(with appropriate quotes, of cause). not write <html lang=nb-no>
or <html lang=no>
@ start of php application file , not using <meta charset=iso-8859-1>
in header either.
the letter substitution not occur in php-admin , not in local installed wordpress. in wamp server 3.0.0. text in english. data stored in mysql have been stored correct. right click on wamp-server icon in system tray , language menu choice gives language list v-mark before english.
how can settings altered firefox/ie/opera/... interpret application correct , display characters in alphabet?
your problem not language, language not influence anything. problem charset.
commons issues in enconding
it common when working accents find strange characters such as:
- like
é
(é
character in unicode), because character unicode, page in iso-8859-1 (or compatible). - the
�
signal/character example of when use compatible accents "iso-8859-1" on page that's trying process "utf-8" because of use ofcontent-type: ...; charset=utf8
.
what needed use utf-8
- php scripts (refer files on server , not answer thereof) must saved in "utf-8 without bom"
- set mysql (or other database system)
charset=utf-8
- it recommended use
header('content-type: text/html; charset=utf-8');
in php scripts (use framework may not necessary, situation varies).
note: advantage of utf-8 can use various "languages" in page characters not supported "iso-8859-1".
about iso-8859-1
i recommend using iso-8859-1 if site not use characters other latin , not need "extra encodings" (such "icons" of "utf-8" or "utf-16"), if no need of utf-8, 1 of reasons might move utf-8, in june 2004, development group of iso/iec responsible maintenance, declared end of support encoding, focusing on ucs , unicode.
source: http://en.wikipedia.org/wiki/iso_8859-1
if decide use utf-8 in site, recommend following steps:
php script utf-8 (without bom)
note: read bom in http://en.wikipedia.org/wiki/utf-8#byte_order_mark
you should save php scripts (yet use include
,require
, etc.) in utf-8 without bom, use programs sublimetext or notepad++ convert files:
using notepad++:
using sublime text:
netbeans got window > preferences > general > workspace > text file encoding:
mysql utf-8
to create table in utf-8 should use like:
create table mytable ( id bigint not null auto_increment primary key, title varchar(300) default null ) engine=innodb character set=utf8 collate utf8_unicode_ci;
if tables existed, first make backup them , use 1 of following commands (as appropriate):
convert database:
alter database mysdatabase character set utf8 collate utf8_unicode_ci;
convert specific table:
alter table mytable convert character set utf8 collate utf8_unicode_ci;
in addition creating tables in utf-8 necessary define connection utf-8.
with pdo use exec
:
$conn = new pdo('mysql:host=host;dbname=mysdatabase', 'user', 'password'); $conn->exec('set character set utf8');//set utf-8
with mysqli use mysqli_set_charset
:
$mysqli = new mysqli('host', 'user', 'password', 'mysdatabase'); if (false === $mysqli->set_charset('utf8')) { printf('error: %s', $mysqli->error); }
setting page charset
you can use <meta>
tag set charset, recommended in response of request (server response), defining "headers" (this not mean should not use <meta>
).
use header
function, reason use server response because page rendering time server response , page "ajax" need charset defined header();
.
note:
header();
should go @ top of script beforeecho ...;
,print "...";
, or other output function.
example:
<?php header('content-type: text/html; charset=utf-8'); echo 'hello world!';
Comments
Post a Comment