Putting $
symbols in an environment variable in a .env
file,
the symfony/dotenv loader seems to mess something up.
.env
TEST=123123123!!!123123123$$LOST$$testtesttest~~~tiltiltiltil
test.php
<?php
require_once __DIR__ . '/vendor/autoload.php';
$dotenv = new \Symfony\Component\Dotenv\Dotenv();
$dotenv->load('.env');
print_r($_ENV);
Output:
[TEST] => 123123123!!!123123123$$~~~tiltiltiltil
Expected output:
[TEST] => 123123123!!!123123123$$LOST$$testtesttest~~~tiltiltiltil
My question is if this is a bug or me doing something wrong.
It does not matter whether I wrap the value in quotes.
If it's not me, I'd create an issue on GitHub.
The $
sign has a special meaning so to insert a literal dollar you need to either quote it or escape it:
TEST='123123123!!!123123123$$LOST$$testtesttest~~~tiltiltiltil'
TEST=123123123!!!123123123\$\$LOST\$\$testtesttest~~~tiltiltiltil
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With