How to decode the url in php where url is encoded with encodeURIComponent()?
I have tried the urldecode() but then also..i don't the url which i have encoded...
I have to do this in php..
PHP | urldecode() Function The urldecode() function is an inbuilt function in PHP which is used to decode url which is encoded by encoded() function. Parameters: This function accepts single parameter $input which holds the url to be decoded. Return Value: This function returns the decoded string on success.
PHP | urlencode() Function. The urlencode() function is an inbuilt function in PHP which is used to encode the url. This function returns a string which consist all non-alphanumeric characters except -_. and replace by the percent (%) sign followed by two hex digits and spaces encoded as plus (+) signs.
encodeURIComponent should be used to encode a URI Component - a string that is supposed to be part of a URL. encodeURI should be used to encode a URI or an existing URL.
You should use rawurldecode()
.
See the Manual
you can use this function:
<?php $string = 'http%3A%2F%2Fexample.com'; $output = preg_replace("/%u([0-9a-f]{3,4})/i","&#x\\1;",urldecode($string)); echo html_entity_decode($output,null,'UTF-8'); ?>
output will be : http://example.com
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With