I want to create a global array inside a controller class in laravel. I searched and explored many resources but couldn't find a proper answer. I want that array to be accessible by all the methods in that controller. Currently I have tried this :
public $members=array(1,2); Global variable
`global $members;` //Inside function
echo $members[0]; //Inside function
I tried to access the data in the array in the function but got a null exception.Please help me out.
Aucun commentaire:
Enregistrer un commentaire