2

I got the basic structure:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">

and the input:

<input type="text" name="var"/>

to get with:

$var = iconv('UTF-8', 'ASCII//TRANSLIT', $_POST['var']);
//or
$var = $_POST['var'];

and show like:

echo $var;
//or
print_r($var);
//or
print_r(iconv('UTF-8', 'ASCII//TRANSLIT', $var));

i try force a new header:

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

and with .htaccess:

AddDefaultCharset UTF-8

and nothing works :( The only things that appears is: jos? instead josé

how solve it?

asdrubal
  • 41
  • 1
  • 1
  • 6

2 Answers2

5

I think this would work for you:

echo utf8_encode($var);

http://php.net/manual/en/function.utf8-encode.php

2

Make sure your files are UTF-8 encoded.

You may also add character encoding to form tag

<form action="demo_form.asp" accept-charset="UTF-8">

jhavrda
  • 403
  • 2
  • 13