第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

PHP 的 call_user_func_array 方法是否效率很低?

PHP 的 call_user_func_array 方法是否效率很低?

PHP
胡說叔叔 2019-03-18 16:53:39
Laravel 5.1 的 Facade 類 的 __callStatic 方法代碼如下: public static function __callStatic($method, $args) { $instance = static::getFacadeRoot(); if (! $instance) { throw new RuntimeException('A facade root has not been set.'); } switch (count($args)) { case 0: return $instance->$method(); case 1: return $instance->$method($args[0]); case 2: return $instance->$method($args[0], $args[1]); case 3: return $instance->$method($args[0], $args[1], $args[2]); case 4: return $instance->$method($args[0], $args[1], $args[2], $args[3]); default: return call_user_func_array([$instance, $method], $args); } } 為什么不直接寫成: public static function __callStatic($method, $args) { $instance = static::getFacadeRoot(); if (! $instance) { throw new RuntimeException('A facade root has not been set.'); } return call_user_func_array([$instance, $method], $args); }
查看完整描述

8 回答

?
ibeautiful

TA貢獻1993條經(jīng)驗 獲得超6個贊

題主是不是看錯了或者看的是修改過的源碼,原始laravel中并沒有發(fā)現(xiàn)存在這些代碼,能否標(biāo)出具體的laravel版本和文件路徑

我看到的laravel的 Facade 類中代碼是這樣的

/**
     * Handle dynamic, static calls to the object.
     *
     * @param  string  $method
     * @param  array   $args
     * @return mixed
     *
     * @throws \RuntimeException
     */
    public static function __callStatic($method, $args)
    {
        $instance = static::getFacadeRoot();

        if (! $instance) {
            throw new RuntimeException('A facade root has not been set.');
        }

        return $instance->$method(...$args);
    }
查看完整回答
反對 回復(fù) 2019-03-18
?
Helenr

TA貢獻1780條經(jīng)驗 獲得超4個贊

這問題我也納悶. mark, 看會不會遇到能解答這個問題的人.

查看完整回答
反對 回復(fù) 2019-03-18
?
梵蒂岡之花

TA貢獻1900條經(jīng)驗 獲得超5個贊

額 題主是什么版本的?。?感覺跟樓上就幾個同學(xué)看到的一樣啊

查看完整回答
反對 回復(fù) 2019-03-18
?
犯罪嫌疑人X

TA貢獻2080條經(jīng)驗 獲得超4個贊

三個...不定參數(shù)的寫法是php 5.6版本才有的新特性,我猜可能框架5.1版本的時候還沒支持php新特性的吧

查看完整回答
反對 回復(fù) 2019-03-18
  • 8 回答
  • 0 關(guān)注
  • 645 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號