mercredi 28 septembre 2016

Use variable across functions

I want to set a variable, which can be used across the functions in a controller using the laravel framework 5.3. The application is running on a server with PHP 5.6.25 installed.

class ProjectController extends Controller{ 
   public $projectid;

   public function index($id){
       $this->projectid = $id;
   }

   public function getProjectid(){
       return $this->projectid;
   }
}

The error I get is: Using $this when not in object context

Thanks in advance for helping.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire