note 118087 added to function.urldecode
| From: | OZLperez11 at gmail dot com | Date: | Thu, 01 Oct 2015 17:26:22 +0000 |
| Subject: | note 118087 added to function.urldecode | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-203888@lists.php.net to get a copy of this message | ||
When sending a string via AJAX POST data which contains an ampersand (&), be sure to use
encodeURIComponent() on the javascript side and use urldecode() on the php side for whatever
variable that was. I've found it tricky to transfer raw ampersands and so this is what worked
for me:
<?php
$_POST["data"] = "one%20%26%20two";
$a = urldecode($_POST["data"); // -> "one & two"
?>
For some reason, a variable with an ampersand would stay encoded while other POST variables were
automatically decoded. I concatenated data from an html form before submitting, in case you wish to
know what happened on the browser end.
----
Server IP: 72.52.91.14
Probable Submitter: 50.84.176.166
----
Manual Page -- http://php.net/manual/en/function.urldecode.php
Edit -- https://master.php.net/note/edit/118087
Del: integrated -- https://master.php.net/note/delete/118087/integrated
Del: useless -- https://master.php.net/note/delete/118087/useless
Del: bad code -- https://master.php.net/note/delete/118087/bad+code
Del: spam -- https://master.php.net/note/delete/118087/spam
Del: non-english -- https://master.php.net/note/delete/118087/non-english
Del: in docs -- https://master.php.net/note/delete/118087/in+docs
Del: other reasons-- https://master.php.net/note/delete/118087
Reject -- https://master.php.net/note/reject/118087
Search -- https://master.php.net/manage/user-notes.php