dscizpq790832708 2014-02-14 12:52
浏览 58
已采纳

将PHP函数参数的默认值声明为“auto”而不是“null”的效果和好处是什么?

In this function in which none some or all arguements can be passed.... what is the effect of calling $useCdn = auto as default as opposed to my current default value of null... generally @useCdn would either be a boolean or null.


public static function framework($extras = false, $debug = null, $useCdn = null)
{
    $type = $extras ? 'more' : 'core';

    // Only load once
    if (!empty(static::$loaded[__METHOD__][$type]))
    {
        return;
    }

    // If no debugging value is set, use the configuration setting
    if ($debug === null)
    {
        $config = JFactory::getConfig();
        $debug = $config->get('debug');
                    if($useCdn === null)
                    {
                        $useCdn = (boolean) $config->get('useCdn');
                    }
    }
            if($useCdn === null || $useCdn === true)
            {
                $config = JFactory::getConfig();
                if($useCdn === null)
                    {
                        $useCdn = (boolean) $config->get('useCdn');
                    }
                 if($useCdn)
                {
                    $cdnMTUri = (strlen($config->get('cdnMTUri'))>0 ? $config->get('cdnMTUri'): null);
                    if($debug)
                    {
                    $cdnMTUri = (strlen($config->get('cdnMTUriD'))>0 ? $config->get('cdnMTUriD'):$cdnMTUri);
                    }
                 }
            }
    if ($type != 'core' && empty(static::$loaded[__METHOD__]['core']))
    {
        static::framework(false, $debug);
    }
            if($useCdn && $cdnMTUri !== null)
            {
                JFactory::getDocument()->addScript($cdnMTUri); 
            }


    JHtml::_('script', 'system/mootools-' . $type . '.js', false, true, false, false, $debug);
    JHtml::_('script', 'system/core.js', false, true);
    static::$loaded[__METHOD__][$type] = true;

    return;
}
  • 写回答

1条回答 默认 最新

  • dongting3135 2014-02-15 09:51
    关注

    $useCdn = auto has no meaning in this context, it's not a PHP type as null .

    There is basically no auto unless you define it as a constant.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 抖音咸鱼付款链接转码支付宝
  • ¥15 ubuntu22.04上安装ursim-3.15.8.106339遇到的问题
  • ¥15 求螺旋焊缝的图像处理
  • ¥15 blast算法(相关搜索:数据库)
  • ¥15 请问有人会紧聚焦相关的matlab知识嘛?
  • ¥15 网络通信安全解决方案
  • ¥50 yalmip+Gurobi
  • ¥20 win10修改放大文本以及缩放与布局后蓝屏无法正常进入桌面
  • ¥15 itunes恢复数据最后一步发生错误
  • ¥15 关于#windows#的问题:2024年5月15日的win11更新后资源管理器没有地址栏了顶部的地址栏和文件搜索都消失了