Create dotenv readEnvFile single function

This commit is contained in:
2021-10-11 08:58:36 +09:00
commit de80a9c061
4 changed files with 166 additions and 0 deletions

25
test/.env Normal file
View File

@@ -0,0 +1,25 @@
# enviroment file
SOMETHING=A
OTHER="B IS B"
Complex="A B \"D is F"
HAS_SPACE= "ABC";
FAILURE = ABC
SIMPLEBOX= A B C
TITLE=1
FOO=1.2
Test="A"
TEST="B"
TEST="D"
LINE="ABC
DEF"
OTHERLINE="ABC
AF\"ASFASDF
MORESHIT"
SUPERLINE=
"asfasfasf"
__FOO_BAR_1 = b
__FOOFOO = f
123123=number
EMPTY=
= flase
asfasdf

15
test/read_env_file.php Normal file
View File

@@ -0,0 +1,15 @@
<?php // phpcs:ignore PSR1.Files.SideEffects
// test read .env file
require '../src/read_env_file.php';
print "BASE: " . __DIR__ . "<br>";
print "ORIG: <pre>" . file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . '.env') . "</pre>";
$status = readEnvFile(__DIR__);
print "STATUS: " . ($status ? 'OK' : 'FAIL') . "<br>";
print "ENV: <pre>" . print_r($_ENV, true) . "</pre><br>";
// __END__