<small id='xV9Ha'></small><noframes id='xV9Ha'>

<tfoot id='xV9Ha'></tfoot>

<i id='xV9Ha'><tr id='xV9Ha'><dt id='xV9Ha'><q id='xV9Ha'><span id='xV9Ha'><b id='xV9Ha'><form id='xV9Ha'><ins id='xV9Ha'></ins><ul id='xV9Ha'></ul><sub id='xV9Ha'></sub></form><legend id='xV9Ha'></legend><bdo id='xV9Ha'><pre id='xV9Ha'><center id='xV9Ha'></center></pre></bdo></b><th id='xV9Ha'></th></span></q></dt></tr></i><div id='xV9Ha'><tfoot id='xV9Ha'></tfoot><dl id='xV9Ha'><fieldset id='xV9Ha'></fieldset></dl></div>
<legend id='xV9Ha'><style id='xV9Ha'><dir id='xV9Ha'><q id='xV9Ha'></q></dir></style></legend>
      <bdo id='xV9Ha'></bdo><ul id='xV9Ha'></ul>

    1. Joomla 使用 JInput 检查空字符串

      时间:2023-10-16

      <small id='g48w8'></small><noframes id='g48w8'>

          <tbody id='g48w8'></tbody>

            <bdo id='g48w8'></bdo><ul id='g48w8'></ul>

          • <tfoot id='g48w8'></tfoot>
                <i id='g48w8'><tr id='g48w8'><dt id='g48w8'><q id='g48w8'><span id='g48w8'><b id='g48w8'><form id='g48w8'><ins id='g48w8'></ins><ul id='g48w8'></ul><sub id='g48w8'></sub></form><legend id='g48w8'></legend><bdo id='g48w8'><pre id='g48w8'><center id='g48w8'></center></pre></bdo></b><th id='g48w8'></th></span></q></dt></tr></i><div id='g48w8'><tfoot id='g48w8'></tfoot><dl id='g48w8'><fieldset id='g48w8'></fieldset></dl></div>

              • <legend id='g48w8'><style id='g48w8'><dir id='g48w8'><q id='g48w8'></q></dir></style></legend>

                本文介绍了Joomla 使用 JInput 检查空字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                按照这个指南来清理我的输入,我想知道是否有一个空字符串被这个覆盖?

                Following this guide to sanitize my inputs, I'm wondering if an empty string is covered with this?

                $jinput = JFactory::getApplication()->input;
                $this->name = $jinput->get('name', '', 'STRING');
                

                如果没有 Joomla,我通常也会检查空字符串.类似的东西:

                Typically without Joomla I'd be checking for an empty string as well. Something like:

                if (!empty($_POST['name']))
                

                查看 JInput get 方法,我看到它检查它是否是 isset:

                Looking at the JInput get method I see that it checks if it is isset:

                public function get($name, $default = null, $filter = 'cmd')
                {
                    if (isset($this->data[$name]))
                    {
                        return $this->filter->clean($this->data[$name], $filter);
                    }
                
                    return $default;
                }
                

                不是一回事,因为 isset 只会检查 null.但是,这是使用 get 方法的默认值.因此,如果我为第二个参数指定一个空字符串,我是否会在这里涵盖?

                Not the same thing, as isset will only check for null. However that is the default value for using the get method. So if I specify an empty string for the second parameter am I covered here?

                $this->name = $jinput->get('name', '', 'STRING');
                

                推荐答案

                Joomla 不能决定您的空字符串是否为有效值.他们必须使用 isset(),因为如果他们使用 empty() 并且您返回 '0' ,这是您期望的正常情况,Joomla 将返回默认值而不是 '0'.

                It's not up to Joomla to decide whether your empty string is valid value or not. They have to use isset(), because if they would use empty() and you return '0' which you would expect as normal, Joomla would return default value instead of that '0'.

                所以他们只是使用 isset() 来检查变量是否被设置是完全正常的,由你决定你接受什么值.

                So it's completely normal that they just use isset() to check if variable is set, and it's up to you to decide what values you accept.

                如果未设置该值,并且您将第二个参数设置为空字符串'',您将得到一个空字符串返回.

                If the value isn't set, and you set as the second parameter empty string '', you'll get an empty string returned.

                在您的示例中,将返回一个空字符串,这是预期的行为.

                In your example an empty string would be returned, which is expected behaviour.

                这篇关于Joomla 使用 JInput 检查空字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:从 Joomla 模块发出重定向 下一篇:使用 akismet 检测注册垃圾邮件发送者

                相关文章

                <small id='YHzaD'></small><noframes id='YHzaD'>

                  <bdo id='YHzaD'></bdo><ul id='YHzaD'></ul>

                  1. <tfoot id='YHzaD'></tfoot>
                    <i id='YHzaD'><tr id='YHzaD'><dt id='YHzaD'><q id='YHzaD'><span id='YHzaD'><b id='YHzaD'><form id='YHzaD'><ins id='YHzaD'></ins><ul id='YHzaD'></ul><sub id='YHzaD'></sub></form><legend id='YHzaD'></legend><bdo id='YHzaD'><pre id='YHzaD'><center id='YHzaD'></center></pre></bdo></b><th id='YHzaD'></th></span></q></dt></tr></i><div id='YHzaD'><tfoot id='YHzaD'></tfoot><dl id='YHzaD'><fieldset id='YHzaD'></fieldset></dl></div>
                    <legend id='YHzaD'><style id='YHzaD'><dir id='YHzaD'><q id='YHzaD'></q></dir></style></legend>