Problem with $ _GET encoding with cyrillic text

I am trying to use this code (on my local web server)

<?php
echo 'the word is /   '.$_GET['word'];
?>

but am I getting a corrupted input result ? word = test

the word is /       

The document is saved as "UTF-8 without specification", and the headers are also UTF-8. I tried urlencode () and urldecode (), but the effect was the same. Uploading it to a web server works fine ...

+5
source share
5 answers

What if you try to send an HTTP header Content-typeto indicate the browser that encodes / encodes your page?

For example, something like this might help:

header('Content-type: text/html; charset=UTF-8');
echo 'the word is /   '.$_GET['word'];

Of course, this is if you are creating HTML - you are probably.


, , , , , - .

: , .

+3

, - Apache.

Apache: "AddDefaultCharset" ( # "AddDefaultCharset off" ), " , - http-equiv xml".

(Apache2 @Ubuntu Linux) "/etc/apache2/conf.d/charset", (Linux/Unix) "/etc/apache2/httpd. conf" "/etc/apache/httpd.conf" ( Apache 1). , "cd/etc/apache2; grep -r AddDefaultCharset *" ( Apache 2 @Unix/Linux).

+2

$_GET AJAX, , blablabla.js UTF-8. iconv("cp1251","utf8",$_GET['word']); $_GET ['word'] UTF-8

0

. !

!

0

, , GET- htmlentities(). , .

0

All Articles