Table of Contents
Home
Backend Development
PHP Tutorial
The application object $app in laravel is written as $app[$k] but no error is reported! Why?



The application object $app in laravel is written as $app[$k] but no error is reported! Why?
laravel
php
In the getConfig
method in the IlluminateFilesystemFilesystemManager
class in laravel 5.1,
actually uses
$this->app['config']["filesystems.disks.{$name}"]);
Copy after login
Copy after login
Return array.
But
$this->app
Copy after login
Copy after login
Obviously a target.
Can an object be retrieved using the key value of an array? This is obviously grammatically wrong but something magical happened anyway
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}"]; }
Copy after login
Copy after login
I alone dd($this->app);
That 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}"]; }
Copy after login
Copy after login
Output
But I dd($this->app'config'); which is
protected function getConfig($name) { dd($this->app['config']["filesystems.disks.{$name}"]); return $this->app['config']["filesystems.disks.{$name}"]; }
Copy after login
Copy after login
Then the output is as follows
In short, $app is obviously an object, how can it be written in the form $app[$k]?