convert str to %20 and the like in JS, then PHP convert back

Javascript coding ..

Moderators: egami, macek, gesf

Post Reply
Jason_C
php-forum Active User
php-forum Active User
Posts: 47
Joined: Sat Nov 18, 2006 7:32 am

Mon Oct 27, 2014 11:49 pm

I have strings's that are causing problems when being sent to a PHP script via JavaScript. (not all of it is getting sent)

i.e.

This is someone's line of text & it's rather long.

I wish to convert the whole string to some other format say like the spaces to %20 and and the & to & I think, and so on...

Then once the PHP script $_GET's the string it converts it back to the original.
User avatar
freshnet
php-forum GURU
php-forum GURU
Posts: 365
Joined: Tue Feb 22, 2011 8:19 am
Location: Canada

Tue Oct 28, 2014 7:01 pm

you may want to look into htmlentities() http://php.net/manual/en/function.htmlentities.php. You could use that and then convert it back if needed in php using html_entity_decode().
Post Reply