简体   繁体   English

Joomla获取/ POST参数忽略字符串中的空格

[英]Joomla Get/POST parameters ignoring white space in string

I am using Joomla 3.4. 我正在使用Joomla 3.4。 And I am using standard Joomla way to GET parameters. 我使用标准的Joomla方式来获取GET参数。 let's assume url contains signup?company=ZITO%20MEDIA,%20LP 我们假设网址包含注册?company = ZITO%20MEDIA,%20LP

According Joomla Standard code 根据Joomla标准代码

$config = new JConfig();
$jinput = JFactory::getApplication()->input;
echo $jinput->get->get('company');

The result: ZITOMEDIALP 结果:ZITOMEDIALP

But if I change the code to standard php code 但是,如果我将代码更改为标准的PHP代码

echo $_GET['company'];

The result: ZITO MEDIA, LP 结果:ZITO MEDIA,LP

I want to use joomla code since I working on joomla project but this is not what I want. 我想使用joomla代码,因为我正在研究joomla项目,但这不是我想要的。

any ideas? 有任何想法吗? and it happens to POST variables as well. 它也发生在POST变量上。

According to the documentation , JInput by default applies the "cmd" filter which basically strips off whatever is not az. 根据文档 ,JInput默认应用“cmd”过滤器,它基本上剥离了不是az的东西。

You should apply the desired filter, eg "int", "string", "word", ... with this syntax: 您应该使用以下语法应用所需的过滤器,例如“int”,“string”,“word”,...

$jinput->get('varname', 'default_value', 'filtername'); 

There is also a shorthand method for most of the filters, for example the following two lines of code are equivalent: 大多数过滤器也有一种速记方法,例如以下两行代码是等效的:

$jinput->get('varname', 'default_value', 'string');
$jinput->getString('varname', 'default_value');

change 更改

$jinput = JFactory::getApplication()->input;
echo $jinput->get->get('company');

to

$jinput = JFactory::getApplication()->input;
echo $jinput->getString('company', 'default_value');

use a default value as well in order to be able to handle the case of a missing parameter. 也使用默认值,以便能够处理缺少参数的情况。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM