Hey guys,
I'm currently working on a PHP project and I am trying to access the variables defined in my .env file using phpdotenv. However, I'm facing a small issue here. Whenever I try to access these variables, I keep getting "\n" instead of the actual value.
Here's how I'm using phpdotenv in my project:
```php
require_once __DIR__ . '/vendor/autoload.php';
$dotenv = Dotenv\Dotenv::createImmutable(__DIR__);
$dotenv->load();
```
And this is how my .env file looks like:
```
DB_HOST=localhost
DB_USER=root
DB_PASS=password
```
To access these variables, I'm using the `$_ENV` superglobal array like this:
```php
$dbHost = $_ENV['DB_HOST'];
$dbUser = $_ENV['DB_USER'];
$dbPass = $_ENV['DB_PASS'];
echo $dbHost; // Outputs "\n" instead of "localhost"
```
I have also tried using `getenv()` and `$_SERVER`, but the issue still persists. Any idea why this is happening? Am I missing something?
Thanks in advance for your help!

Hi there,
I've encountered a similar issue with phpdotenv before, and it can be a bit perplexing. The "\n" output rather than the expected values typically indicates that the .env file is not being loaded or read correctly.
Firstly, double-check that the path to your .env file is accurate and it is located in the right directory. Sometimes a small typo in the file path can cause issues. It's always a good idea to verify the path.
Next, ensure that you have installed the phpdotenv package correctly. You can try running `composer update` to make sure you have the latest version installed.
Another thing to consider is the file encoding of your .env file. You could try saving the file with a different encoding, such as UTF-8, to see if it resolves the problem.
If the issue still persists, you might want to try using an alternative method to load the variables from your .env file. One approach is using the `parse()` method provided by the phpdotenv library. Here's an example:
You can then access the variables using the `$envArray` array:
This method directly parses the .env file, which might help resolve the issue.
Give these suggestions a try and let us know if you're still encountering any problems. Feel free to provide more details about your project setup for further assistance. Best of luck!