Global variable in laravel 4

前端 未结 6 552
萌比男神i
萌比男神i 2020-12-07 23:17

I was wondering how to do a global variable to save me few lines of copy and pasting this lines. Array it probably and put them in one variable instead? I want to use this

6条回答
  •  眼角桃花
    2020-12-08 00:05

    The best way i've seen is by using a config file.

    In your app -> config folder, you create a new file called (for example settings.php)

     app
         config
             settings.php
    

    Then in your configuration file you just created (settings.php) you could add:

    You can then retrieve the config file from your code using:

    echo Config::get('settings.foo'); // Will echo bar
    echo Config::get('settings.bar'); // Will echo foo
    

提交回复
热议问题