I have a folder named source in my laravel 5.4 application which i use quiet often in my controller code.
For example the statement public_path() . '/source/' is used in many places in my code and so I want to define the public_path() . '/source/' directory as a controller level variable. This way I will just have to use the variable name in all controller functions that use the directory.
This is what I tried and was surprised to see it fail:
class PostController extends Controller
{
public $source_dir = public_path() . '/source/';
}
But on the line where $source_dir is defined, the application gives the following error:
FatalErrorException syntax error, unexpected '(', expecting ',' or ';'
Thanks for any help!
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire