在laravel 5.1里的
IlluminateFilesystemFilesystemManager 类中的
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] 这样的形式呢?
Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
ArrayAccess