If you know laravel, you can take a look at the above section. if you don't know about it, go straight to the split line ;. for any item in env, use MAIL_DRIVER as an example to change it to "my". use the env function to get the value normally. change it to "I" and use the env function to get the value normally; {code ...} other... if you know laravel, you can take a look at the above section. if you don't know about it, go straight to the split line below;
Any item in. env takes MAIL_DRIVER as an example.
Change to "my" and use the env function to get the value normally;
Changed to "I" and the env function won't be available;
MAIL_DRIVER = my var_dump (env (MAIL_DRIVER ''); // NULLMAIL_DRIVER = my var_dump (env (MAIL_DRIVER''); // My
Other Chinese characters, such as "good", will also encounter this situation;
I have to say that laravel is profound and profound. I have studied the env function source code;
The final problem is;
----------------------------------------------- Understand and do not understand the split line of the laravel framework ------------------------------------------------
Putenv ("PROJECT_NAME = my"); phpinfo ();
In phpinfo, Environment can be searched for PROJECT_NAME.
Putenv ("PROJECT_NAME = Me"); phpinfo ();
In phpinfo, Environment cannot find PROJECT_NAME.
Ask your friends. why? How can I set Chinese values without barriers?
Reply content:
If you know laravel, you can take a look at the above section. if you don't know about it, go straight to the split line below;
Any item in. env takes MAIL_DRIVER as an example.
Change to "my" and use the env function to get the value normally;
Changed to "I" and the env function won't be available;
MAIL_DRIVER = my var_dump (env (MAIL_DRIVER ''); // NULLMAIL_DRIVER = my var_dump (env (MAIL_DRIVER''); // My
Other Chinese characters, such as "good", will also encounter this situation;
I have to say that laravel is profound and profound. I have studied the env function source code;
The final problem is;
----------------------------------------------- Understand and do not understand the split line of the laravel framework ------------------------------------------------
Putenv ("PROJECT_NAME = my"); phpinfo ();
In phpinfo, Environment can be searched for PROJECT_NAME.
Putenv ("PROJECT_NAME = Me"); phpinfo ();
In phpinfo, Environment cannot find PROJECT_NAME.
Ask your friends. why? How can I set Chinese values without barriers?
I also tried it and found that as long as it is called in the cgi environmentPutenv ('Project _ NAME = drop ')
And so on (four bytes, the same for Japanese kana ).false
In the cli environment:
Region ~ $ Php-r "var_dump (putenv ('Project _ NAME = MY'); echo getenv ('Project _ name');" bool (true) me
I am also fascinated by the fact that Google cannot find a similar situation. I hope other people will have a good answer.
However, since the subject uses Laravelputenv
, Just to get it.env
You can use the following tips:
In your own projecthelpers.php
To add a new function (or another place where the custom help function is put:
if (! function_exists('menv')) { /** * Gets the value of an environment variable by getenv() or $_ENV. * * @param string $key * @param mixed $default * @return mixed */ function menv($key, $default = null) { if (function_exists('putenv') && function_exists('getenv')) { // try to read by getenv() $value = getenv($key); if ($value === false) { return value($default); } } else { // try to read from $_ENV or $_SERVER if (isset($_ENV[$key])) { $value = $_ENV[$key]; } elseif (isset($_SERVER[$key])) { $value = $_SERVER[$key]; } else { return value($default); } } switch (strtolower($value)) { case 'true': case '(true)': return true; case 'false': case '(false)': return false; case 'empty': case '(empty)': return ''; case 'null': case '(null)': return; } if (strlen($value) > 1 && Str::startsWith($value, '"') && Str::endsWith($value, '"')) { return substr($value, 1, -1); } return $value; }}
Define a new function for getting environment variables andconfig/
Allenv
Replacemenv
(I tried$_ENV
,$_SERVER
Will not be affected)
For more information, see here. it was originally intended for some users not to useputenv
All you have done is