TransWikia.com

Laravel does not read .env variables when there is a # character

Stack Overflow Asked by helderam on December 23, 2020

In Laravel 7 when I do a simple:

$test_secret = env('TEST_SECRET');
echo 'Secret : ' . $test_secret;
exit;

the output is always:

Secret: 123

And my .env file is:

APP_NAME=Laravel
APP_ENV=local
TEST_SECRET=123#456#789

I am waiting for a response : "Secret: 123#456#789". And don’t understand why I receive only "Secret: 123".

I know it is a trivial question, but I am on this problem…

Thanks

One Answer

# is used to declare a comment in the .env file. Wrap the var's value in quotes.

TEST_SECRET="123#456#789"

Correct answer by lagbox on December 23, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP