Laravel 9 access .env variable in blade

 In Laravel 9, you can access the variables defined in the .env file in your blade views using the env function.

Here's an example of how to use the env function in a blade view:

<title>{{ env('APP_NAME') }}</title>

In this example, we're using the env function to retrieve the value of the APP_NAME variable from the .env file and use it as the title of the page.

You can also provide a default value to the env function in case the variable is not defined in the .env file:

<title>{{ env('APP_NAME', 'My Laravel App') }}</title>

In this example, if the APP_NAME variable is not defined in the .env file, the title of the page will be set to "My Laravel App".


Most Popular

Remove Unicode Zero Width Space PHP

PhpStorm, return value is expected to be 'A', 'object' returned

Laravel file upload returns forbidden 403, file permission is 700 not 755