PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Friday, March 18, 2022

[FIXED] When use $_GET to get string in cakephp plus bacome blank

 March 18, 2022     cakephp     No comments   

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
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home
View mobile version

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing