1

When I input data such as : Œ, œ, Ÿ, ... , ,ドル ≤, ≥, ∞, ≈, ≠, – , — , ‐ , ‐ , ‹ ›, " ", ‘ ’ And then try to access data from the $_REQUEST['some_value'] I get this as my output

1⁄4, 1⁄2, 3⁄4, … , ¤, ≤, ≥, ∞, ≈, ≠, – , — , ‐ , ‑ , ‹ ›, “ ”, ‘ ’

What exactly is happening here?

Abdulla Nilam
39.9k18 gold badges85 silver badges115 bronze badges
asked Dec 9, 2024 at 6:40
0

1 Answer 1

-1

We call this Character encoding.

When you input special characters, PHP converts them to their HTML entity representations. This happens when PHP processes form submissions or access request data.

To handle this, you can use this on page

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

if AJAX,

contentType: 'application/x-www-form-urlencoded; charset=UTF-8',

Where to place PHP header


FYI: To check data use echo htmlspecialchars($value); But when processing $originalValue = $_REQUEST['some_value']; is enough.

answered Dec 9, 2024 at 6:58
Sign up to request clarification or add additional context in comments.

1 Comment

Where does that "PHP converts them" quote come from? 'Cause it's wrong. PHP doesn't convert anything to HTML entities per se.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.