In PHP, I have already understood that double arrow ( => ) is used with arrays to assign a value to the key and the object operator ( -> ) is used to access the properties of objects (methods and variables).
Please take a look at the following code:
public function show() {
$items = Test::all();
return view('display'['item'=> $items]);
}
Could anyone explain what exactly the double arrow ( => ) operator is doing here and how it is possible in this context?
foreach($items as $item) {
echo $item->name;
}
As per the definition the left side of the object operator ( -> ) must be an instance variable. Then how this operator is applicable here?