I'm sending a url that has special characters in them.
/contacts?advanceSearch=true&advanceSearchType=rating&advanceSearchValue=A1A+
As you see the variable value of advanceSearchValue is A1A+
But when I retrieve this in controller
$this->params()->fromQuery("advanceSearchValue");
it shows me A1A. It adds space instead of +
This is my route config.
"contacts" => [
"type" => "segment",
"options" => [
"route" => "/contacts[/:action[/:id]]",
"defaults" => [
"controller" => Controller\ContactController::class,
"action" => "index",
],
],
],
This is because
+has a special meaning in a URL and Zend knows this and correctly replaces it with a space.To get a
+character into the parsed data you need to URL escape it. This gives the value%2B.So your full URL should be
By the way, what is producing this URL, a web browser should be automatically converting the + character before sending it to the web server?