Issue
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
.
Solution
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
Answered By - Salines
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.