dimanche 18 octobre 2020

Can't understand a logic of Object And Array in php

If i wrote this line on Laravel's routes/web.php

dd( app()['config']["auth.guards.web"] );

It outputs this:

array:2 [▼
  "driver" => "session"
  "provider" => "users"
]

Thats cool, but my question is since app()['config'] returns an object so how this ["auth.guards.web"]works? Even there is no index with that name!
Outside of laravel I tried to write a class named Test, so that it returns same output but i got an error! Which is,

Fatal error: Uncaught Error: Cannot use object of type Test as array 

Can anyone explain it with core php?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire