Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

php javascript url encoding

I have a html text. I had encoded it in php using urlencode function. I want to decode that text in the javascript. when i use unescape function in javascript it replaces all the special characters back but sapce is replaced by '+'. how can i do it correctly so that space is replaced as space itself???

like image 885
Andromeda Avatar asked Jul 09 '09 17:07

Andromeda


People also ask

How encode URL in PHP?

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.

How decode URL in PHP?

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.

What is decodeURIComponent?

The decodeURIComponent() function decodes a Uniform Resource Identifier (URI) component previously created by encodeURIComponent or by a similar routine.


1 Answers

PHP rawUrlEncode() == JavaScript encodeURIComponent()

PHP rawUrlDecode() == JavaScript decodeURIComponent()

like image 95
Yasen Avatar answered Sep 23 '22 00:09

Yasen