A
A
alex--n2017-09-08 15:43:48
Laravel
alex--n, 2017-09-08 15:43:48

Why does the system not always respond to the .env file?

Good afternoon. There is a file with .env. It contains all sorts of different variables, such as data for entering the database and all that. Added a custom field In the future I use it like this
ISPROD=0

if(env('ISPROD') === 0)
        {
            $company =  iconv("UTF-8", "WINDOWS-1251", $company);
            $file= iconv("UTF-8", "WINDOWS-1251", $file);
            echo "iconv";
        }

And this is not always done, for some inexplicable reason it is sometimes not done. For example, this code is executed when several images are loaded (not simultaneously, ajax). When one download completes, the second one starts.
And sometimes it turns out that in the response either
iconvOk
or
Ok
(Ok is sent a little later and gets into the response)
The variable in the file does not change. I was looking for reasons in the pictures and in general the transmitted data, but he throws out absolutely randomly. What is the reason for this behaviour?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
B
BoShurik, 2017-09-08
@BoShurik

Try replacing if(env('ISPROD') === 0)
with if($_SERVER['ISPROD'] === 0)

S
s_sitp, 2017-09-08
@s_sitp

env('ISPROD') === 0 // false
env('ISPROD') == 0 // true
env returns a string, and you have strict equality

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question