Problems with characters in php

software development

#1

Hi everybody.

When I have a simple php file with something like this:

echo “español”

it prints in the screen:

“espa?ol”

the same with accents like áéíóú and other characters.

Do you know how to solve this?

I have this meta:

in the HTML so I think that the problem is because other things…

In the server the files are fine, but when I execute the php it doesn’t return the expected result.

Any idea about how to solve?


#2

Easiest way is just to use the ascii code for it, try this one: ń

JagaLaw


#3

I know, this is good & ntilde ;

but what about when I receive data from the user with no format?

And is really really weird, because I have a file with this code:

<?php echo "áéñ"; ?>

and for instance is I call this way:
file.php?id=4

It display fine, but if I call
file.php?id=2

is not fine, and there is no treatment at all of the parameters (as you can see, one line of code…).


#4

Use PHP to set the character encoding. Put this line at the beginning of each page:<?php header("Content-Type: text/html; charset=utf-8"); ?>You can also force all PHP files to be UTF-8 by default by adding this line to your .htaccess file:AddCharset UTF-8 .php--------
si-blog | Keystone Websites
Save $97 on yearly plans with promo code [color=#CC0000]SCJESSEY97[/color]


#5

are you sure your files are utf8? the default on windows systems is windows-1252

track7 - my dream-hosted site


#6

As you say, that was the problem, files were not in UTF-8 format. Now everything works fine.

And there were also a cache problem, when the browser saw a page in a specified format it always used it from that moment.

Thank you all :wink: