<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 检查空字符串

      Joomla check for empty string with JInput(Joomla 使用 JInput 检查空字符串)

      <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 检查空字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)
                  <tbody id='YHzaD'></tbody>

                <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>