Comments (7)
I'm not sure. PHP_EOL
should be your system's end of line character. I just did some research though and it seems like "\r\n"
is best for wide compatability. Can you verify that explode("\r\n", ... )
works on your system?
from phpdotenv.
"\r\n"
doesn't work. It still doesn't break each line into a value. It just throws everything into $lines[0]
(same as PHP_EOL
). It's odd that it doesn't work since I have the same setup on a different local virtual server and deployment server and they both work fine. There's nothing different about this setup, yet it still won't work without using "\n"
.
from phpdotenv.
I've the same problem. I'm using IIS to simulate PHP and to parse the Dotenv class.
Apparently the PHP_EOL
doesn't contain any line-break information, but explode("\n", ... );
does work on my system.
Update:
At a closer look, I think the PHP_EOL
does contain a "\r\n"
, however, it of course doesn't fix the problem because only the "\n"
here.
And I found a similar topic about this: avalanche123/doxphp#7
from phpdotenv.
I don't think you should rely on PHP_EOL
.
I would recommend using something like this: http://stackoverflow.com/questions/11066857/detect-eol-type-using-php
from phpdotenv.
It seems like PHP_EOL
is a good practice when creating new lines dynamically, not when exploding.
http://stackoverflow.com/questions/4975411/when-do-i-use-php-eol-instead-of-n-and-vice-versa-ajax-jquery-client-problem
Perhaps you can use the first answer:
$lines = array_map("rtrim", explode("\n", $fc));
Or something similar since it will break on old macs. Perhaps something like this, I've tested this and it works fine at my system:
$lines = preg_split('/\r\n|\r|\n/', $fc);
from phpdotenv.
This worked for me
ini_set("auto_detect_line_endings", true);
$lines = file($filePath);
It uses PHP's auto line detection (see: L852), which appears to be more or less the same as the last line of @harm-less's post.
I'd recommend going with his method on the off chance a user might not be happy with changing an ini setting (although you could use ini_get()
and then change it back afterwards, but whatever; doesn't seem like that's necessary).
from phpdotenv.
This has been fixed.
from phpdotenv.
Related Issues (20)
- Unable to read the "/tmp/build_2f06b5cf/.env" environment file HOT 1
- auto_detect_line_endings is deprecated (PHP 8.1 + dotenv v2.6.9) HOT 1
- PHP version 7.1 is not supported now HOT 2
- Equals Symbol in last line of multiline variable causes issues. HOT 3
- Save to .env HOT 1
- How to loads many env file, but the extension is .txt HOT 1
- Fatal error: Uncaught Error: Class "Dotenv\Dotenv" not found in HOT 1
- Performance degradation HOT 3
- Question - are there any 'builtin' variables? HOT 3
- Add reader with support for secret files
- loading a .env file from outside the webspace seem to not work
- php 8.2 function getenv() not set HOT 1
- Please dont use $_SERVER HOT 1
- Load AWS system environments HOT 4
- symfony/dotenv Correlation HOT 1
- PHP version 7.4 HOT 1
- How does this help with php_value in .htaccess?
- Is there anyway to use sections created in the .env file? HOT 4
- Fatal error: Uncaught Error: Class "Dotenv\Dotenv" not found in HOT 2
- Can one use Heredoc syntax for multi-line strings? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from phpdotenv.