Browsing Decode

Preventing double encode of URL in PHP

There is no practical way to check whether an URL is encoded or not to encode if it’s not encoded. But you can do encode the URL by first decoding like below: $string = url_decode($url); And then you should encode as to prevent double encoding. $string = url_encode($url); By doing this we can prevent double encoding of URL‘s.


Encode/Decode URL in Javascript and PHP

URL encoding and decoding can be done in both Javascript and PHP. In this post I’m going to tell you the functions used in both languages for url encoding/decoding. Javascript Encoding encodeURIComponent(url); Decoding decodeURIComponent(url); PHP Encoding urlencode(url); Decoding urldecode(url); There is an encodeURI and decodeURI function in Javascript but it won’t encode/decode the url. Note that the the word used in Javascript is URI not URL.







This blog was once on WordPress. Now a static site. See source code on