DarkLeafyGreen
DarkLeafyGreen

Reputation: 70466

Pass text with special characters as get parameter in php

I want to pass any text as a get parameter to a php script. For know I just append the text this way:

action.php?text=Hello+my+name+is+bob

This url is composed by javascript and I do a ajax request with this url.

In action.php I do

$encoded = array_map('rawurlencode', $_GET);

But this does not work for special chars like ÖÄüä.

Any idea how to solve this?

Upvotes: 2

Views: 6615

Answers (2)

Greg Flynn
Greg Flynn

Reputation: 1744

url_encode(string) will return the given string with special characters converted into %XX format.

https://www.php.net/manual/en/function.urlencode.php

I know you can send special characters fine without encoding through $_POST, which is another alternative

Upvotes: 3

dynamic
dynamic

Reputation: 48141

try with url_encode().........

Upvotes: 2

Related Questions