MaCi
MaCi

Reputation: 173

PHP input parameter encoding

A simple question: what is the encoding of the input parameters in PHP? I mean GET, POST and so on.

Running some tests, I found that probably they are UTF-8 encoded. Can this be true?

Upvotes: 0

Views: 404

Answers (2)

eis
eis

Reputation: 53482

They are in the encoding browser sends them. You can (and should) suggest the browser to use some encoding, like page meta character set or form accept-charset, for example:

<form action="form_action.php" accept-charset="UTF-8">

but you cannot force it. However, if you want to, you can also filter out all input data that is not in the encoding you suggested.

This is not specific to PHP, but applies in general.

Upvotes: 2

Jon
Jon

Reputation: 437386

It depends entirely on what was sent with the HTTP request. If the browser sends UTF-8 encoded data, that's what you will read from PHP.

Upvotes: 1

Related Questions