添加%20,而不是空格 [英] %20 is added instead of spaces
问题描述
我想这是一个小问题,但我不得不问这里,因为我在我的项目中跑得很快。当我将字符串传递给另一个控制器中的函数时,它将空格变为%20符号。我想控制器认为该字符串作为url传递并编码。但是我不知道如何删除它,或者如果可能,不要让它将空格改为%20。这里是我使用的代码;
I guess this is small issue but yet i had to ask here since i am running short in my project. When I pass string to the function in another controller, it changes spaces into %20 sign. I guess the controller thinks the string passed as url and encodes it. But I don't know exactly how to remove it or if possible do not let it to change spaces into %20. Here is the code which i use;
$message="The user name you provided is already in our database";
redirect('admin/add_user/'.$message);
这是我的控制器函数,我收到该消息;
Here is my controller function where i receive the message;
public function add_user($message)
{
echo $message;
}
我也试过这样做:
public function add_user()
{
echo $this->uri->segment(3);
}
但结果是一样的。这是字符串的输出;
But the result is same. Here is the output of the string;
The%20user%20name%20you%20provided%20is%20already%20in%20our%20database
推荐答案
尝试:
public function add_user($message)
{
echo urldecode($message);
}
您可以在这里阅读关于urldecode的更多信息:http://php.net/manual/en/function.urldecode.php
这篇关于添加%20,而不是空格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!