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;

the output is always:

Secret: 123

And my .env file is:


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…


One Answer

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


Correct answer by lagbox on December 23, 2020

Add your own answers!

Ask a Question

Get help from others!

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