Clothess Sale
Clothess Sale

Reputation: 41

Php how to make valid url

I have file on my server. The name contains 'Ihre Bestellung bei Ticketcorner für Swiss Indoors Basel', but 'ü' is not valid for url.

How can I make it valid or recoded?

I found mb_convert_encoding function

I tried it:

 $sImageName = mb_convert_encoding($sImageName,"ASCII");

But it returns f?r and can't save the file.

Also tried it:

$sImageName = rawurldecode($sImageName);

But both methods don't work. Maybe I need another format for it?

How can I fix it and get valid url?

Also try on page use urlencode() and i get 'f%C3%BCr' but when i open link it replace it to 'für' and it doesnt work.

Upvotes: 0

Views: 79

Answers (1)

nice_dev
nice_dev

Reputation: 17825

When passing the data in the URL, you have to urlencode() it and then send it in the URL.

<?php

echo  urlencode('Ihre Bestellung bei Ticketcorner für Swiss Indoors Basel');

While receiving the data, you will have to urldecode() it to get back the original string.

<?php

echo  urldecode(urlencode('Ihre Bestellung bei Ticketcorner für Swiss Indoors Basel'));

Upvotes: 2

Related Questions