The hexadecimal value you are looking for is %2B
To get it automatically in PHP run your string through urlencode($stringVal)
. And then run it rhough urldecode($stringVal)
to get it back.
If you want the JavaScript to handle it, use escape( str )
Edit
After @bobince's comment I did more reading and he is correct.
Use encodeURIComponent(str)
and decodeURIComponent(str)
. Escape will not convert the characters, only escape them with \
's