In the laravel 5.1 .
In the Illuminatefilesystemfilesystemmanager class
In the getconfig method
actually use
$this->app['config']["filesystems.disks.{$name}"]);
Returns an array.
But
$this->app
It's an object, obviously.
Can objects use the value of an array's key values? It's syntactically wrong, but the magic is still happening.
This is the GetConfig method.
/** * Get the filesystem connection configuration. * * @param string $name * @return array */ protected function getConfig($name) { return $this->app['config']["filesystems.disks.{$name}"]; }
I am alone DD ($this->app);
is as follows
/** * Get the filesystem connection configuration. * * @param string $name * @return array */ protected function getConfig($name) { dd($this->app); return $this->app['config']["filesystems.disks.{$name}"]; }
Output
But I dd ($this->app ' config ');
protected function getConfig($name) { dd($this->app['config']["filesystems.disks.{$name}"]); return $this->app['config']["filesystems.disks.{$name}"]; }
Then the output is as follows
In short $app is clearly an object, how can write $app [$k] this form?
Reply content:
In the laravel 5.1 .
In the Illuminatefilesystemfilesystemmanager class
In the getconfig method
actually use
$this->app['config']["filesystems.disks.{$name}"]);
Returns an array.
But
$this->app
It's an object, obviously.
Can objects use the value of an array's key values? It's syntactically wrong, but the magic is still happening.
This is the GetConfig method.
/** * Get the filesystem connection configuration. * * @param string $name * @return array */ protected function getConfig($name) { return $this->app['config']["filesystems.disks.{$name}"]; }
I am alone DD ($this->app);
is as follows
/** * Get the filesystem connection configuration. * * @param string $name * @return array */ protected function getConfig($name) { dd($this->app); return $this->app['config']["filesystems.disks.{$name}"]; }
Output
But I dd ($this->app ' config ');
protected function getConfig($name) { dd($this->app['config']["filesystems.disks.{$name}"]); return $this->app['config']["filesystems.disks.{$name}"]; }
Then the output is as follows
In short $app is clearly an object, how can write $app [$k] this form?
The app inherits from IlluminateContainerContainer
, and Container implements it ArrayAccess
(Http://php.net/manual/zh/clas ... Interface The Arrayaccess interface provides the ability to access an object like an array, as long as several methods of implementing the interface can invoke Isset, unset, [] to access the value.
$this->app['config']
IlluminateConfigRepository
It also implements the arrayaccess, so it can also be used as an array.
ArrayAccess