在laravel 5.1裡的
IlluminatesystemFilesystemManager 類別中的
getConfig方法中
竟然用
$this->app['config']["filesystems.disks.{$name}"]);
返回數組。
但是
$this->app
明明是個對像啊。
物件能用陣列的鍵值取值嗎? 這在文法上明明是錯的但是神奇的事情還是發生了
這是getConfig方法
/** * Get the filesystem connection configuration. * * @param string $name * @return array */ protected function getConfig($name) { return $this->app['config']["filesystems.disks.{$name}"]; }
我單獨dd($this->app);
即如下
/** * Get the filesystem connection configuration. * * @param string $name * @return array */ protected function getConfig($name) { dd($this->app); return $this->app['config']["filesystems.disks.{$name}"]; }
輸出
但是我dd($this->app'config');即
protected function getConfig($name) { dd($this->app['config']["filesystems.disks.{$name}"]); return $this->app['config']["filesystems.disks.{$name}"]; }
那麼輸出如下
總之 $app 明明是個對象,怎麼能寫成 $app[$k] 這樣的形式呢?