0

I'm use $_GET to get str in cakephp like this. $str = $_GET['str'] ,and the url like be this http://test.loc/test.php?str=sss+sss

And the $str is going to be sss sss, plus become blank. And I want to get the $str be sss+sss.

code.g
  • 143
  • 1
  • 1
  • 14

1 Answers1

0

Make your life easy ;)

CakePHP has methods which handles with request & response.

https://book.cakephp.org/3.0/en/controllers/request-response.html

example:

// return string || null
$str = $this->getRequest()->getQuery('str');

// replace blank / white space with + character
$str = str_replace(' ', '+', $str);

// or better use Text class
$str = Text::slug($str, '+');

https://book.cakephp.org/3.0/en/core-libraries/text.html#creating-url-safe-strings

Note:

'+' are special characters in the query component

Salines
  • 5,674
  • 3
  • 25
  • 50