2

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

6
  • 3
    because # is used to declare a comment ... wrap the env var value in quotes Commented Nov 13, 2020 at 6:01
  • i am not sure it works or not but try 123\#456\#789 Commented Nov 13, 2020 at 6:02
  • @lagbox this would probably worth an answer, however, I didn't check if there are dupes Commented Nov 13, 2020 at 6:04
  • 1
    @Cid I didn't mark it as duplicate Commented Nov 13, 2020 at 6:07
  • 2
    I'm usually a dupe hunter, however, this question, although simple, is nicely written (title and content are good) and will certainly help future readers Commented Nov 13, 2020 at 6:08

1 Answer 1

6

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

TEST_SECRET="123#456#789"
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.