LoginSignup
1
0

More than 5 years have passed since last update.

phpdotenvが複数行に対応

Last updated at Posted at 2019-04-13

phpdotenvがV3から

NAME="VALUE
VALUE
VALUE"

に対応しました。

.env

TEXT="aaa
bbb
ccc"
phpdotenv2.php
<pre>
<?php
include('autoload.php');
use Dotenv\Dotenv;

$dotenv = new Dotenv(__DIR__);
$dotenv->load();
var_dump($_ENV);
?>

/*
array(1) {
  ["TEXT"]=>
  string(3) "aaa"
}
*/
phpdotenv3.php
<pre>
<?php
include('autoload.php');
use Dotenv\Dotenv;

$dotenv = Dotenv::create(__DIR__);
$dotenv->load();
var_dump($_ENV);
?>

/*
array(1) {
  ["TEXT"]=>
  string(11) "aaa
bbb
ccc"
}
*/

ちなみに.envが

TEXT="aaa

だと上記コードの出力は

V2
array(1) {
  ["TEXT"]=>
  string(3) "aaa"
}

V3
array(0) {
}
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0